Handle importing pkg.mod by executing

__import__('mod', {'__packaging__': 'pkg', level=1) w/o properly (and
thus not segfaulting).
This commit is contained in:
Brett Cannon 2012-04-14 21:50:00 -04:00
parent 59f9c3affc
commit 49f8d8b016
4 changed files with 276 additions and 253 deletions

View file

@ -1083,7 +1083,7 @@ def __import__(name, globals={}, locals={}, fromlist=[], level=0):
return module
else:
cut_off = len(name) - len(name.partition('.')[0])
return sys.modules[module.__name__[:-cut_off]]
return sys.modules[module.__name__[:len(module.__name__)-cut_off]]
else:
return _handle_fromlist(module, fromlist, _gcd_import)