Improve absolute import management for iptest.py

Bug #506112 reported by Fernando Perez
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
IPython
Triaged
Medium
Fernando Perez

Bug Description

On Mon, Jan 11, 2010 at 11:36 AM, Jörgen Stenarson <email address hidden> wrote:
> I often run IPython/testing/iptest.py as a script but this is not possible
> now due to a relative import:
>
> C:\python\external\ipython-perez\IPython>python testing\iptest.py
> Traceback (most recent call last):
> File "testing\iptest.py", line 39, in <module>
> from . import globalipapp
> ValueError: Attempted relative import in non-package

Argh, yes. This is unfortunately only fixed for 2.6:

http://www.python.org/dev/peps/pep-0366/

We might just add that boilerplate

if __name__ == "__main__" and __package__ is None:
    __package__ = "expected.package.name"

protected by a version check, so your approach continues to work.

Changed in ipython:
assignee: nobody → Fernando Perez (fdo.perez)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.