Skip to content

python3 syntax error in _decorator.py #753

Closed

Description

@jtorrents

While working on the script for testing pull requests I noticed a python 3 syntax error in line 153 networkx/external/decorator/_decorator.py. It is strange because the error is not raised during the tests (thus they pass) but during the setup of the virtualenv. To reproduce the error run the test_pr.py script from #752 with python3.2 installed. Notice that despite the error tests are actually run with python3.2

  File "/home/jtorrents/.nx_pr_tests/venv-python3.2/lib/python3.2/site-packages/networkx/external/decorator/_decorator.py", line 153
    exec code in evaldict
            ^
SyntaxError: invalid syntax

Activity

  1. hagberg commented on Aug 10, 2012

    @hagberg
    Member

    There are two versions of the decorator code _dectorator.py (Python2.x) and _decorator3.py (Python3.x) with a dispatch from init.py in that directory. So _decorator.py should never get run by Python3.
    I guess the virtualenv setup is calling that somehow?

  2. jtorrents commented on Aug 10, 2012

    @jtorrents
    MemberAuthor

    I see, I didn't look closely because the test_pr.py script is working fine despite this error. I'll try to see why and how is virtualenv calling the 2.x version of _decorator.py. I'm closing this issue.

  3. takluyver commented on Aug 10, 2012

    @takluyver

    Depending on how your setup.py works, it might try to byte-compile all the Python files it installs, which will pick up on invalid syntax. If that's what you're seeing, it's most likely harmless.

  4. jtorrents commented on Aug 12, 2012

    @jtorrents
    MemberAuthor

    Hi Thomas,

    You are right. All files are byte-compiled at install time, so the python2 only files throw Syntax Error when using python3.2. This doesn't prevent a correct installation, so it seems harmless. The commit above pipes STDERR to STDOUT when installing NetworkX, so the error message is written to the log and doesn't show up in the screen while running test_pr.py.

    Thanks for the feedback, and for test_pr.py and friends!

  5. takluyver commented on Aug 12, 2012

    @takluyver

    You're welcome! At some point I might spin test_pr out into a separate project that can be used for multiple projects, so it's good to see someone else using it.

  6. jtorrents commented on Aug 12, 2012

    @jtorrents
    MemberAuthor

    I like test_pr a lot, it is small, simple and easy to modify. If you create a separate project I'll be one of your first users ;)

    Salut!

  7. takluyver commented on Aug 12, 2012

    @takluyver

    Thanks - one of the reasons I haven't spun it out into a separate project
    is that I worry it would rapidly gain complexity to handle the requirements
    of different projects.

    I'm thinking of insisting projects use a standard way to run tests,
    something like: we will install your project in a virtualenv, then call
    "import Foo; Foo.test()". We already have IPython.test(), although test_pr
    doesn't use it at present. Then all the configuration it needs for a
    project should be:

    [ipython]
    github_repo = ipython/ipython
    package_name = IPython

    I see you're already doing something similar in your variant of the script,
    but specifying arguments to .test(). Would it be acceptable for .test() to
    be called with the default arguments if test_pr became a generic thing?

  8. hagberg commented on Aug 12, 2012

    @hagberg
    Member

    On Sun, Aug 12, 2012 at 11:47 AM, Thomas Kluyver
    [email protected]:

    Thanks - one of the reasons I haven't spun it out into a separate project
    is that I worry it would rapidly gain complexity to handle the requirements
    of different projects.

    I'm thinking of insisting projects use a standard way to run tests,
    something like: we will install your project in a virtualenv, then call
    "import Foo; Foo.test()". We already have IPython.test(), although test_pr
    doesn't use it at present. Then all the configuration it needs for a
    project should be:

    [ipython]
    github_repo = ipython/ipython
    package_name = IPython

    I see you're already doing something similar in your variant of the script,
    but specifying arguments to .test(). Would it be acceptable for .test() to
    be called with the default arguments if test_pr became a generic thing?

    Sure that would be fine.
    Aric

  9. jtorrents commented on Aug 12, 2012

    @jtorrents
    MemberAuthor

    2012/8/12 Thomas Kluyver [email protected]

    Thanks - one of the reasons I haven't spun it out into a separate project
    is that I worry it would rapidly gain complexity to handle the requirements
    of different projects.

    I'm thinking of insisting projects use a standard way to run tests,
    something like: we will install your project in a virtualenv, then call
    "import Foo; Foo.test()". We already have IPython.test(), although test_pr
    doesn't use it at present. Then all the configuration it needs for a
    project should be:

    [ipython]
    github_repo = ipython/ipython
    package_name = IPython

    I see you're already doing something similar in your variant of the script,
    but specifying arguments to .test(). Would it be acceptable for .test() to
    be called with the default arguments if test_pr became a generic thing?

    That seems reasonable and a good approach. As Aric says we could make
    the necessary changes for calling nx,test() with the default
    arguments.

    Salut!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions