summaryrefslogtreecommitdiffstats
path: root/Lib/newimp.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-05-05 15:50:56 (GMT)
committerGuido van Rossum <guido@python.org>1995-05-05 15:50:56 (GMT)
commitb1c1315ba309b00625f19f2cf24c0cbd27b88ca5 (patch)
treee884113d4202811848545ad77b64358ab8114a23 /Lib/newimp.py
parent2db6bfcd1d08e6d596671db00fff7af98cae645e (diff)
downloadcpython-b1c1315ba309b00625f19f2cf24c0cbd27b88ca5.zip
cpython-b1c1315ba309b00625f19f2cf24c0cbd27b88ca5.tar.gz
cpython-b1c1315ba309b00625f19f2cf24c0cbd27b88ca5.tar.bz2
new release by Ken, fix handling of from
Diffstat (limited to 'Lib/newimp.py')
-rwxr-xr-xLib/newimp.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/Lib/newimp.py b/Lib/newimp.py
index e671de8..3f1a6b2 100755
--- a/Lib/newimp.py
+++ b/Lib/newimp.py
@@ -68,9 +68,9 @@ also denoted in the module by '__package__'. Additionally, modules have
associated with them a '__pkgpath__', a path by which sibling modules are
found."""
-__version__ = "$Revision$"
+__version__ = "Revision: 1.13"
-# $Id$ First release:
+# Id: newimp.py,v 1.13 1995/04/13 23:23:33 klm Exp First release:
# Ken.Manheimer@nist.gov, 5-Apr-1995, for python 1.2
# Developers Notes:
@@ -250,10 +250,16 @@ def import_module(name,
return (container or theMod)
else:
# Implement 'from': Populate immediate env with module defs:
- if froms == '*':
- froms = theMod.__dict__.keys() # resolve '*'
- for item in froms:
- (envLocals or envGlobals)[item] = theMod.__dict__[item]
+ while froms:
+ item = froms[0]; del froms[0]
+ if item == '*':
+ froms = theMod.__dict__.keys() + froms
+ else:
+ try:
+ (envLocals or envGlobals)[item] = theMod.__dict__[item]
+ except KeyError:
+ raise ImportError, ("name '%s' not found in module %s" %
+ (item, theMod.__name__))
return theMod
def unload(module):