diff lib/pkgdata.py @ 1553:ebd545641c8b

merging with python3 branch r 2048
author Lenard Lindstrom <len-l@telus.net>
date Sat, 02 May 2009 01:03:14 +0000
parents 052feee00091
children ae2160cc5b0e
line wrap: on
line diff
--- a/lib/pkgdata.py	Thu Apr 30 04:41:45 2009 +0000
+++ b/lib/pkgdata.py	Sat May 02 01:03:14 2009 +0000
@@ -20,7 +20,8 @@
 __all__ = ['getResource']
 import sys
 import os
-from cStringIO import StringIO
+from pygame.compat import get_BytesIO
+BytesIO = get_BytesIO()
 
 try:
     from pkg_resources import resource_stream, resource_exists
@@ -52,7 +53,7 @@
     mod = sys.modules[pkgname]
     fn = getattr(mod, '__file__', None)
     if fn is None:
-        raise IOError, "%r has no __file__!"
+        raise IOError("%s has no __file__!" % repr(mod))
     path = os.path.join(os.path.dirname(fn), identifier)
     loader = getattr(mod, '__loader__', None)
     if loader is not None:
@@ -61,5 +62,5 @@
         except IOError:
             pass
         else:
-            return StringIO(data)
-    return file(os.path.normpath(path), 'rb')
+            return BytesIO(data)
+    return open(os.path.normpath(path), 'rb')