mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
new release by Ken, fix handling of from
This commit is contained in:
parent
2db6bfcd1d
commit
b1c1315ba3
1 changed files with 12 additions and 6 deletions
|
@ -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
|
associated with them a '__pkgpath__', a path by which sibling modules are
|
||||||
found."""
|
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
|
# Ken.Manheimer@nist.gov, 5-Apr-1995, for python 1.2
|
||||||
|
|
||||||
# Developers Notes:
|
# Developers Notes:
|
||||||
|
@ -250,10 +250,16 @@ def import_module(name,
|
||||||
return (container or theMod)
|
return (container or theMod)
|
||||||
else:
|
else:
|
||||||
# Implement 'from': Populate immediate env with module defs:
|
# Implement 'from': Populate immediate env with module defs:
|
||||||
if froms == '*':
|
while froms:
|
||||||
froms = theMod.__dict__.keys() # resolve '*'
|
item = froms[0]; del froms[0]
|
||||||
for item in froms:
|
if item == '*':
|
||||||
(envLocals or envGlobals)[item] = theMod.__dict__[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
|
return theMod
|
||||||
|
|
||||||
def unload(module):
|
def unload(module):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue