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

Don't use "exec" in find_class(). It's slow, unnecessary, and (as AMK

points out) it doesn't work in JPython Applets.
üst 605ebddb
...@@ -661,15 +661,14 @@ class Unpickler: ...@@ -661,15 +661,14 @@ class Unpickler:
dispatch[GLOBAL] = load_global dispatch[GLOBAL] = load_global
def find_class(self, module, name): def find_class(self, module, name):
env = {}
try: try:
exec 'from %s import %s' % (module, name) in env __import__(module)
except ImportError: mod = sys.modules[module]
klass = getattr(mod, name)
except (ImportError, KeyError, AttributeError):
raise SystemError, \ raise SystemError, \
"Failed to import class %s from module %s" % \ "Failed to import class %s from module %s" % \
(name, module) (name, module)
klass = env[name]
return klass return klass
def load_reduce(self): def load_reduce(self):
......
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