diff options
-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" % \ |