Fail to import pyparsing 2.1.2 in Python 3.4 and 3.3
Brought to you by:
ptmcg
Hi,
I found the issue when using matplotlib.
In Python 3.4 and 3.3, importing pyparsing 2.1.2 fails with a message "AttributeError: 'tuple' object has no attribute 'filename'".
$ python3.4 -V Python 3.4.4 $ python3.4 -m venv venv3.4 $ . venv3.4/bin/activate (venv3.4) $ pip install pyparsing==2.1.2 (venv3.4) $ python Python 3.4.4 (default, Apr 23 2016, 23:16:11) [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import pyparsing Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/private/tmp/venv3.4/lib/python3.4/site-packages/pyparsing.py", line 3478, in <module> _escapedPunc = Word( _bslash, r"\[]-*.$+^?()~ ", exact=2 ).setParseAction(lambda s,l,t:t[0][1]) File "/private/tmp/venv3.4/lib/python3.4/site-packages/pyparsing.py", line 948, in setParseAction self.parseAction = list(map(_trim_arity, list(fns))) File "/private/tmp/venv3.4/lib/python3.4/site-packages/pyparsing.py", line 808, in _trim_arity this_line = extract_stack()[-1] File "/private/tmp/venv3.4/lib/python3.4/site-packages/pyparsing.py", line 793, in extract_stack return [(frame_summary.filename, frame_summary.lineno)] AttributeError: 'tuple' object has no attribute 'filename' >>>
Same as Python 3.3:
$ python3.3 -V Python 3.3.6 $ virtualenv venv3.3 --python=python3.3 $ . venv3.3/bin/activate (venv3.3)$ pip install pyparsing==2.1.2 (venv3.3)$ python Python 3.3.6 (default, Feb 4 2016, 19:46:05) [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import pyparsing Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/private/tmp/venv3.3/lib/python3.3/site-packages/pyparsing.py", line 3478, in <module> _escapedPunc = Word( _bslash, r"\[]-*.$+^?()~ ", exact=2 ).setParseAction(lambda s,l,t:t[0][1]) File "/private/tmp/venv3.3/lib/python3.3/site-packages/pyparsing.py", line 948, in setParseAction self.parseAction = list(map(_trim_arity, list(fns))) File "/private/tmp/venv3.3/lib/python3.3/site-packages/pyparsing.py", line 808, in _trim_arity this_line = extract_stack()[-1] File "/private/tmp/venv3.3/lib/python3.3/site-packages/pyparsing.py", line 793, in extract_stack return [(frame_summary.filename, frame_summary.lineno)] AttributeError: 'tuple' object has no attribute 'filename' >>>
Using Python 3.5 or importing pyparsing 2.1.1 does not fail.
$ python3.5 -V Python 3.5.1 $ python3.5 -m venv venv3.5 $ . venv3.5/bin/activate (venv3.5) $ pip install pyparsing==2.1.2 (venv3.5) $ python Python 3.5.1 (default, Apr 18 2016, 03:49:24) [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import pyparsing >>>
Thanks! Yes, it looks like I only ran my unit tests on 2.7 and 3.5, not on 3.3 or 3.4.
I can confirm the issue.
(FWIW I can highly recommend tox as a standardized way of running tests against all supported Python versions. Using a CI service like Travis CI you could do so in an automated way without going through the hassle of installing all versions locally. I'm not sure if there's a comparable thing with sourceforge integration however, so you'd probably need to set up a GitHub mirror or switch to Git/GitHub entirely if you wanted to use it)
Well, I now have a VM with a number of Python versions installed using
pyenv, so that I can quickly switch between versions for testing. Found that
my 3.5-compatible code was really only 3.5.0-compatible, and that in 3.5.1,
a change in the traceback module changed the depth of the call stack, so I
needed to make another change as well. I think there is probably one more
convergence version that I'll need to release, but things look smoother for
now.
I've also downloaded tox to my VM, but I may be able to automate my testing
using just pyenv and some simple shell scripting. But thanks for the tip!
-- Paul
From: The Compiler [mailto:thecompiler@users.sf.net]
Sent: Wednesday, May 11, 2016 7:46 AM
To: [pyparsing:bugs] 95@bugs.pyparsing.p.re.sf.net
Subject: [pyparsing:bugs] #95 Fail to import pyparsing 2.1.2 in Python 3.4
and 3.3
I can confirm the issue.
(FWIW I can highly recommend tox https://testrun.org/tox/ as a
standardized way of running tests against all supported Python versions.
Using a CI service like Travis CI https://www.travis-ci.org/ you could do
so in an automated way without going through the hassle of installing all
versions locally. I'm not sure if there's a comparable thing with
sourceforge integration however, so you'd probably need to set up a GitHub
mirror or switch to Git/GitHub entirely if you wanted to use it)
[bugs:#95] https://sourceforge.net/p/pyparsing/bugs/95/ Fail to import
pyparsing 2.1.2 in Python 3.4 and 3.3
Status: open
Group: v1.0 (example)
Created: Wed May 11, 2016 05:25 AM UTC by orangain
Last Updated: Wed May 11, 2016 12:14 PM UTC
Owner: nobody
Hi,
I found the issue when using matplotlib.
Problem
In Python 3.4 and 3.3, importing pyparsing 2.1.2 fails with a message
"AttributeError: 'tuple' object has no attribute 'filename'".
How to Reproduce
$ python3.4 -V
Python 3.4.4
$ python3.4 -m venv venv3.4
$ . venv3.4/bin/activate
(venv3.4) $ pip install pyparsing==2.1.2
(venv3.4) $ python
Python 3.4.4 (default, Apr 23 2016, 23:16:11)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Same as Python 3.3:
$ python3.3 -V
Python 3.3.6
$ virtualenv venv3.3 --python=python3.3
$ . venv3.3/bin/activate
(venv3.3)$ pip install pyparsing==2.1.2
(venv3.3)$ python
Python 3.3.6 (default, Feb 4 2016, 19:46:05)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Workaround
Using Python 3.5 or importing pyparsing 2.1.1 does not fail.
$ python3.5 -V
Python 3.5.1
$ python3.5 -m venv venv3.5
$ . venv3.5/bin/activate
(venv3.5) $ pip install pyparsing==2.1.2
(venv3.5) $ python
Python 3.5.1 (default, Apr 18 2016, 03:49:24)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Sent from sourceforge.net because you indicated interest in
https://sourceforge.net/p/pyparsing/bugs/95/
To unsubscribe from further messages, please visit
https://sourceforge.net/auth/subscriptions/
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Related
Bugs:
#95Fixed in 2.1.3, just released
Thanks for the prompt fix! I confirmed the problem was fixed in 2.1.3.
I agree with The Compiler and also recommend you to use tox. Using tox, people who have an interest in pyparsing can easily run tests by the simple command
tox
.tox.ini
in pyparsing will be simple enough like: