diff options
author | Guido van Rossum <guido@python.org> | 1997-03-14 04:21:10 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-03-14 04:21:10 (GMT) |
commit | efd3a3a843b15c05696ba4ac8c23b00d9d9a24ce (patch) | |
tree | 5bccfb7667fde613ce9c9962e08e4dd0c3b2e301 /Lib/pickle.py | |
parent | c69955343c8cad265aeafe93b6afc4f1589fd084 (diff) | |
download | cpython-efd3a3a843b15c05696ba4ac8c23b00d9d9a24ce.zip cpython-efd3a3a843b15c05696ba4ac8c23b00d9d9a24ce.tar.gz cpython-efd3a3a843b15c05696ba4ac8c23b00d9d9a24ce.tar.bz2 |
Implement find_class() without exec statement.
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r-- | Lib/pickle.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py index 28f8f90..bfe49f9 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -465,14 +465,12 @@ class Unpickler: dispatch[CLASS] = load_class def find_class(self, module, name): - env = {} try: - exec 'from %s import %s' % (module, name) in env - except ImportError: + klass = getattr(__import__(module), name) + except (ImportError, AttributeError): raise SystemError, \ "Failed to import class %s from module %s" % \ (name, module) - klass = env[name] if type(klass) is BuiltinFunctionType: raise SystemError, \ "Imported object %s from module %s is not a class" % \ |