mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
Make functionality more closely the same as what's implemented by default.
This commit is contained in:
parent
501d0bb7ad
commit
4f9f8e3599
1 changed files with 12 additions and 8 deletions
20
Lib/knee.py
20
Lib/knee.py
|
|
@ -63,13 +63,22 @@ def load_tail(q, tail):
|
|||
raise ImportError, "No module named " + mname
|
||||
return m
|
||||
|
||||
def ensure_fromlist(m, fromlist):
|
||||
def ensure_fromlist(m, fromlist, recursive=0):
|
||||
for sub in fromlist:
|
||||
if sub == "*":
|
||||
if not recursive:
|
||||
try:
|
||||
all = m.__all__
|
||||
except AttributeError:
|
||||
pass
|
||||
else:
|
||||
ensure_fromlist(m, all, 1)
|
||||
continue
|
||||
if sub != "*" and not hasattr(m, sub):
|
||||
subname = "%s.%s" % (m.__name__, sub)
|
||||
submod = import_module(sub, subname, m)
|
||||
## if not submod:
|
||||
## raise ImportError, "No module named " + subname
|
||||
if not submod:
|
||||
raise ImportError, "No module named " + subname
|
||||
|
||||
def import_module(partname, fqname, parent):
|
||||
try:
|
||||
|
|
@ -108,8 +117,3 @@ def reload_hook(module):
|
|||
# Now install our hooks
|
||||
__builtin__.__import__ = import_hook
|
||||
__builtin__.reload = reload_hook
|
||||
|
||||
# pretend we're ni, too
|
||||
sys.modules['ni'] = sys.modules[__name__]
|
||||
def ni(): pass
|
||||
def install(): pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue