Skip to content

Loading…

Improve absolute import management for iptest.py #60

Closed
ipython opened this Issue · 1 comment

2 participants

@ipython

Original Launchpad bug 506112: https://bugs.launchpad.net/ipython/+bug/506112
Reported by: fdo.perez (Fernando Perez).

On Mon, Jan 11, 2010 at 11:36 AM, Jörgen Stenarson jorgen.stenarson@bostream.nu 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 
>    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.

@fperez
IPython: interactive computing in Python member

This is now fixed in master, closing.

@fperez fperez closed this
@damianavila damianavila referenced this issue
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.