Kaydet (Commit) efd3a3a8 authored tarafından Guido van Rossum's avatar Guido van Rossum

Implement find_class() without exec statement.

üst c6995534
......@@ -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" % \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment