Menu

nonlocal doesn't worl with 2.X

andrewsben
2012-12-16
2013-07-17
  • andrewsben

    andrewsben - 2012-12-16

    line 629 of pyparser sets nonlocal variables limit and foundArity.  In python 2.X nonlocal variables are read only and cannot be set.  In the following lines setting them is attempted. 

    'decorator to trim function calls to match the arity of the target'
    def _trim_arity(func, maxargs=3):
        if func in singleArgBuiltins:
            return lambda s,l,t: func(t)
        limit = 0
        foundArity = False
        def wrapper(*args):
            nonlocal limit,foundArity
            while 1:
                try:
                    ret = func(*args)
                    foundArity = True
                    return ret
                except TypeError:
                    if limit == maxargs or foundArity:
                        raise
                    limit += 1
                    continue
        return wrapper

    Error i am seeing is:

      File "/tmp/easy_install-7t56MV/pyparsing-2.0.0/pyparsing.py", line 629
        nonlocal limit,foundArity
                     ^
    SyntaxError: invalid syntax

     
  • Paul McGuire

    Paul McGuire - 2012-12-16

    Pyparsing 2.0.0 is for Python 3 only - latest pyparsing version for Python 2.x is 1.5.7.

     
  • Paul McGuire

    Paul McGuire - 2012-12-16

    To do this with easy_install, use the command "easy_install pyparsing==1.5.7"

     
  • andrewsben

    andrewsben - 2012-12-16

    Thanks for the information.  Will alter my script to force 1.5.7.

     
  • Marcel Stimberg

    Marcel Stimberg - 2013-02-27

    It's of course fine to have newer versions only support Python 3 but the way this change is introduced is probably breaking a lot of automatic testing code (like mine) that just uses the newest pyparsing version available. In addition, installation via "easy_install pyparsing" and "pip install pyparsing" is impossible on Python 2 and does not give any useful error message.

    I'm not sure:  Does pip take the package meta-data into account? If yes, removing "Programming Language :: Python" and only keeping "Programming Language :: Python :: 3" might prevent pip from trying to install it under python 2.

    Either way, I think it would be a good idea to add a check to setup.py, something along the lines of:

    if sys.hexversion <= 0x03000000:
      raise Exception('This version of pyparsing requires Python 3, 1.5.7 is the last version supporting Python 2.')
    

    Oh, and the README file still states:
    "(pyparsing requires Python 2.3.2 or later.)"

     
  • francoise

    francoise - 2013-03-18

    I am unable to install the 1.5.7 release with pip :

    $ pip install pyparsing==1.5.7
    

    It's like the 1.5.7 release was overwritten by the new version ?

     
  • Jimmy Royer

    Jimmy Royer - 2013-03-27

    Same problem over here, I cannot install with

    pip install pyparsing==1.5.7
    

    and the documentation for version 2.0.0 still list 2.3.2 as compatible. I had to come here to find out. Any place where we can download a previous version?

     
  • Anonymous

    Anonymous - 2013-04-04

    If you tried to install the lastest version before, you need to clear the pip cache  before trying to install a previous version

     
  • Anonymous

    Anonymous - 2013-04-17

    I see http://www.2gather.in/?p=98

    And solved this with

    $ pip install https://pypi.python.org/packages/source/p/pyparsing/pyparsing-1.5.7.tar.gz
    
     
  • Dan Gayle

    Dan Gayle - 2013-07-08
    pip install pyparsing==1.5.6    
    pip install pyparsing==1.5.7
    

    ^ Doesn't work on Python 2.7.5

    easy_install pyparsing==1.5.7
    

    ^ Works

    What's more concerning is that pyparsing is part of Celery's requirements, and it borks on this error trying to install.

     

    Last edit: Dan Gayle 2013-07-08
    • Paul McGuire

      Paul McGuire - 2013-07-17

      Thanks for the reminder - I'm checking in version 2.0.1 of pyparsing, which
      will be compatible with Pythons 2.6 and 2.7 also.

      -- Paul

      From: Dan Gayle [mailto:dangayle@users.sf.net]
      Sent: Monday, July 08, 2013 6:45 PM
      To: [pyparsing:discussion]
      Subject: [pyparsing:discussion] nonlocal doesn't worl with 2.X

      pip install pyparsing==1.5.7

      ^ Doesn't work on Python 2.7.5

      pip install pyparsing==1.5.6

      ^ Works

      What's more concerning is that pyparsing is part of Celery's requirements,
      and it borks on this error trying to install.


      nonlocal doesn't worl with 2.X
      https://sourceforge.net/p/pyparsing/discussion/337293/thread/fa00ffd7/?limi t=25#2ce7


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/pyparsing/discussion/337293/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.