summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-03-25 21:58:59 (GMT)
committerGuido van Rossum <guido@python.org>1999-03-25 21:58:59 (GMT)
commit397032aa46e82c1891e11cc33121b80a04b3bcc7 (patch)
treef90b0d28c87a93276dacb8a51d9d8aac7855703c
parent605ebddbeab6fe05908fe4dfb6e1c4b8a9f7deee (diff)
downloadcpython-397032aa46e82c1891e11cc33121b80a04b3bcc7.zip
cpython-397032aa46e82c1891e11cc33121b80a04b3bcc7.tar.gz
cpython-397032aa46e82c1891e11cc33121b80a04b3bcc7.tar.bz2
Don't use "exec" in find_class(). It's slow, unnecessary, and (as AMK
points out) it doesn't work in JPython Applets.
-rw-r--r--Lib/pickle.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index fda4bd7..7164eb1 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -661,15 +661,14 @@ class Unpickler:
dispatch[GLOBAL] = load_global
def find_class(self, module, name):
- env = {}
-
try:
- exec 'from %s import %s' % (module, name) in env
- except ImportError:
+ __import__(module)
+ mod = sys.modules[module]
+ klass = getattr(mod, name)
+ except (ImportError, KeyError, AttributeError):
raise SystemError, \
"Failed to import class %s from module %s" % \
(name, module)
- klass = env[name]
return klass
def load_reduce(self):