pygame / lib /

Diff from to

File lib/

 __all__ = ['getResource']
 import sys
 import os
-from cStringIO import StringIO
+from pygame.compat import get_BytesIO
+BytesIO = get_BytesIO()
+    from pkg_resources import resource_stream, resource_exists
+except ImportError:
+    def resource_exists(package_or_requirement, resource_name):
+        return False
+    def resource_stream(package_of_requirement, resource_name):
+        raise NotImplementedError
 def getResource(identifier, pkgname=__name__):
     rather than use it as a file-like object.  For example, you may
     be handing data off to a C API.
+    if resource_exists(pkgname, identifier):
+        return resource_stream(pkgname, identifier)
     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:
         except IOError:
-            return StringIO(data)
-    return file(os.path.normpath(path), 'rb')
+            return BytesIO(data)
+    return open(os.path.normpath(path), 'rb')