[issue14592] old-style (level=-1) importing broken after importlib changes

2012-04-17 Thread Brett Cannon
Brett Cannon added the comment: SystemError fixed (stemming from a misunderstanding of what PyDict_GetItemWithError() did). -- assignee: -> brett.cannon resolution: -> fixed stage: -> committed/rejected status: open -> closed ___ Python tracker

[issue14592] old-style (level=-1) importing broken after importlib changes

2012-04-17 Thread Roundup Robot
Roundup Robot added the comment: New changeset 68f9ad6a3b13 by Brett Cannon in branch 'default': Issue #14592: A relative import will raise a KeyError if __package__ http://hg.python.org/cpython/rev/68f9ad6a3b13 -- nosy: +python-dev ___ Python tracke

[issue14592] old-style (level=-1) importing broken after importlib changes

2012-04-17 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis : -- nosy: +Arfrever ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscri

[issue14592] old-style (level=-1) importing broken after importlib changes

2012-04-17 Thread Brett Cannon
Brett Cannon added the comment: Detecting if you are in a package is as simple as ``'.' in __name__ or hasattr(mod, '__path__')`` or alternatively for the last guard, ``__name__ == __package__``. As for the failure, I will have a look. -- ___ Pyth

[issue14592] old-style (level=-1) importing broken after importlib changes

2012-04-16 Thread Stefan Behnel
Stefan Behnel added the comment: Hmm, interesting - it stripped the command from my e-mail. I was doing this: >>> __import__("sys", level=1) Traceback (most recent call last): File "", line 1, in SystemError: error return without exception set -- ___

[issue14592] old-style (level=-1) importing broken after importlib changes

2012-04-16 Thread Stefan Behnel
Stefan Behnel added the comment: > Yeah, the fix is dead-simple, import with level=1 and if that fails import > with level=0. With one caveat: relative imports don't work outside of packages, so the importing code has to know when it's in a package or not. Otherwise, the relative import would

[issue14592] old-style (level=-1) importing broken after importlib changes

2012-04-16 Thread Brett Cannon
Brett Cannon added the comment: Yeah, the fix is dead-simple, import with level=1 and if that fails import with level=0. I plan to cover this specific issue in the "What's New" for Python 3.3. -- ___ Python tracker

[issue14592] old-style (level=-1) importing broken after importlib changes

2012-04-16 Thread Stefan Behnel
Stefan Behnel added the comment: It turns out that it wasn't all that hard to work around. Calling __import__ twice seems to do the trick. It's more overhead, but if people want speed, they can just be explicit about what kind of import they actually mean. So I wouldn't mind considering this

[issue14592] old-style (level=-1) importing broken after importlib changes

2012-04-16 Thread Eric Snow
Changes by Eric Snow : -- nosy: +eric.snow ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.o

[issue14592] old-style (level=-1) importing broken after importlib changes

2012-04-16 Thread Brett Cannon
Brett Cannon added the comment: I should also mention that the support for -1 indexing in Python 3 was weird because support was partially removed, but some 'if' checks only did ``< 1`` and so negative indices didn't trigger an error. -- ___ Python

[issue14592] old-style (level=-1) importing broken after importlib changes

2012-04-16 Thread Brett Cannon
Brett Cannon added the comment: What Benjamin said. PEP 328 should have done away with relative imports, but somehow the __import__() function itself was not updated even though its docs were changed to say that index defaulted to 0. So this isn't actually a regressions because of importlib b

[issue14592] old-style (level=-1) importing broken after importlib changes

2012-04-16 Thread Benjamin Peterson
Benjamin Peterson added the comment: By "relative" I meant "sibling". -- ___ Python tracker ___ ___ Python-bugs-list mailing list Uns

[issue14592] old-style (level=-1) importing broken after importlib changes

2012-04-16 Thread Benjamin Peterson
Benjamin Peterson added the comment: Relative imports are no longer supported in python 3, so this makes sense. -- nosy: +benjamin.peterson ___ Python tracker ___ __

[issue14592] old-style (level=-1) importing broken after importlib changes

2012-04-16 Thread R. David Murray
Changes by R. David Murray : -- nosy: +brett.cannon ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail

[issue14592] old-style (level=-1) importing broken after importlib changes

2012-04-16 Thread Stefan Behnel
New submission from Stefan Behnel : Up to the early Py3.3 developer versions, calling __import__() with a level of -1 worked as in Python 2, i.e. it tried a relative import first and then a global import. This no longer seems to be available after the importlib rewrite (e.g. as of rev f341b99