Commits

Jason R. Coombs committed 9f715c5

Use importlib instead of __import__

Comments (0)

Files changed (3)

 Changes
 -------
 
+2.1.1
+~~~~~
+
+ * Use importlib instead of __import__ for programmatic imports.
+
+2.1
+~~~
+
+ * Added .insert on lists.
+
 2.0
 ~~~
 
 import threading
+import importlib
 
 import limpy.types
 from . import dictlib
 		name = name_map.get(name, name)
 		module_name, sep, class_name = name.rpartition('.')
 		if not module_name: module_name = '__builtin__'
-		mod = __import__(module_name, fromlist=[class_name],
-			level = 0, #absolute import
-		)
+		mod = importlib.import_module(module_name)
 		if class_name == 'NoneType': return type(None)
 		if class_name == 'unary': return 'unary'
 		class_ = getattr(mod, class_name)
 		name = name_map.get(name, name)
 		module_name, sep, class_name = name.rpartition('.')
 		if not module_name: module_name = '__builtin__'
-		mod = __import__(module_name, fromlist=[class_name],
-			level = 0, #absolute import
-		)
+		mod = importlib.import_module(module_name)
 		class_ = getattr(mod, class_name)
 		return class_
 
+import sys
 
 import setuptools
 
 with open('README') as f:
 	long_description = f.read()
 
+importlib_req = ['importlib'] if sys.version_info < (2,7) else []
+
 setup_params = dict(
 	name="LimPy",
 	use_hg_version=dict(increment='1.0'),
 	install_requires=[
 		'ply == 3.4',
 		'zope.interface',
-	],
+	] + importlib_req,
 	setup_requires=[
 		'hgtools>=1.0',
 		'pytest-runner',