src/reportlab/__init__.py
changeset 4260 58d91bf065e0
parent 4259 c740bbf613b9
child 4261 8ad30c29b9af
--- a/src/reportlab/__init__.py	Wed Mar 30 15:06:02 2016 +0100
+++ b/src/reportlab/__init__.py	Mon Apr 04 14:17:58 2016 +0100
@@ -5,7 +5,7 @@
 __version__=Version
 __date__='20160330'
 
-import sys, os, imp
+import sys, os
 
 if sys.version_info[0:2]!=(2, 7) and sys.version_info<(3, 3):
     raise ImportError("""reportlab requires Python 2.7+ or 3.3+; 3.0-3.2 are not supported.""")
@@ -20,11 +20,23 @@
     builtins.cmp = cmp
     builtins.xrange = range
     del cmp, builtins
+    def _fake_import(fn,name):
+        from importlib import machinery
+        m = machinery.SourceFileLoader(name,fn)
+        try:
+            return m.load_module(name)
+        except FileNotFoundError:
+            raise ImportError('file %s not found' % ascii(fn))
 else:
     from future_builtins import ascii
     import __builtin__
     __builtin__.ascii = ascii
     del ascii, __builtin__
+    def _fake_import(fn,name):
+        if os.path.isfile(fn):
+            import imp
+            with open(fn,'rb') as f:
+                imp.load_source(name,fn,f)
 
 #try to use dynamic modifications from
 #reportlab.local_rl_mods.py
@@ -34,11 +46,6 @@
 except ImportError:
     pass
 
-def _fake_import(fn,name):
-    if os.path.isfile(fn):
-        with open(fn,'rb') as f:
-            imp.load_source(name,fn,f)
-
 try:
     import reportlab_mods   #application specific modifications can be anywhere on python path
 except ImportError: