Hide Forgot
Description of problem: pyflakes seems not to work with CPython 2, running via CPython 3 works fine. See also: https://bitbucket.org/tarek/flake8/issue/130/traceback-in-v21-attributeerror Version-Release number of selected component: pyflakes-0.7.2-1.fc19 Additional info: reporter: libreport-2.1.9 cmdline: python -m pyflakes orges dso_list: python-libs-2.7.5-9.fc19.x86_64 executable: /usr/lib/python2.7/site-packages/pyflakes/__main__.py kernel: 3.11.10-200.fc19.x86_64 runlevel: N 5 type: Python uid: 1000 Truncated backtrace: checker.py:722:LAMBDA:AttributeError: 'arguments' object has no attribute 'kwonlyargs' Traceback (most recent call last): File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/usr/lib/python2.7/site-packages/pyflakes/__main__.py", line 5, in <module> main(prog='pyflakes') File "/usr/lib/python2.7/site-packages/pyflakes/api.py", line 128, in main warnings = checkRecursive(args, reporter) File "/usr/lib/python2.7/site-packages/pyflakes/api.py", line 119, in checkRecursive warnings += checkPath(sourcePath, reporter) File "/usr/lib/python2.7/site-packages/pyflakes/api.py", line 86, in checkPath return check(codestr, filename, reporter) File "/usr/lib/python2.7/site-packages/pyflakes/api.py", line 58, in check w = checker.Checker(tree, filename) File "/usr/lib/python2.7/site-packages/pyflakes/checker.py", line 253, in __init__ self.handleChildren(tree) File "/usr/lib/python2.7/site-packages/pyflakes/checker.py", line 520, in handleChildren self.handleNode(node, tree) File "/usr/lib/python2.7/site-packages/pyflakes/checker.py", line 555, in handleNode handler(node) File "/usr/lib/python2.7/site-packages/pyflakes/checker.py", line 702, in FUNCTIONDEF self.LAMBDA(node) File "/usr/lib/python2.7/site-packages/pyflakes/checker.py", line 722, in LAMBDA for arg in node.args.args + node.args.kwonlyargs: AttributeError: 'arguments' object has no attribute 'kwonlyargs' Local variables in innermost frame: node: <_ast.FunctionDef object at 0x140c090> self: <pyflakes.checker.Checker object at 0x1403890> args: []
Created attachment 834520 [details] File: backtrace
Created attachment 834521 [details] File: environ
The code where the problem occurs should never be run with python 2.x, so I suppose something's tripping pyflakes' check for python version. Do you happen to have a module named "builtins" in your python path?
Yes, the module builtins exists. I added this code at the top of my setup.py: [...] import builtins print(builtins) import sys sys.exit() [...] With it I get the following output when running as usual: $ python setup.py flake8 <module 'builtins' from '/usr/lib/python2.7/site-packages/builtins.pyc'> Note that I am running python2.7 while in the linked flake8 issue, someone is getting a similar error using python2.6.
Created attachment 834794 [details] Workaround patch Oh, a module named builtins from something else besides python itself doesn't sound like a good idea to me. I suppose it doesn't come from a Fedora package (repoquery produces no hits), maybe it's from some other package? "rpm -qf /usr/lib/python2.7/site-packages/builtins.pyc" would tell. Anyway, I guess the attached patch would work around it in pyflakes, but it's just trading the name "builtins" for "__builtin__" which can be (ab)used the same way so it's not really a good fix, IMHO this should be fixed in whatever installs the "builtins" module in your setup in the first place.
No, the file did not come from a Fedora or another rpm package. I managed to find the PyPI package using pip: $ pip show -f pies2overrides --- Name: pies2overrides Version: 2.0.1 Location: /usr/lib/python2.7/site-packages Requires: ipaddress Files: ../configparser.py ../builtins.py ../_thread.py ../copyreg.py ../queue.py ../reprlib.py ../socketserver.py ../html/entities.py ../html/__init__.py ../html/parser.py ../http/cookies.py ../http/client.py ../http/cookiejar.py ../http/server.py ../http/__init__.py ../xmlrpc/client.py ../xmlrpc/__init__.py ../configparser.pyc ../builtins.pyc ../_thread.pyc ../copyreg.pyc ../queue.pyc ../reprlib.pyc ../socketserver.pyc ../html/entities.pyc ../html/__init__.pyc ../html/parser.pyc ../http/cookies.pyc ../http/client.pyc ../http/cookiejar.pyc ../http/server.pyc ../http/__init__.pyc ../xmlrpc/client.pyc ../xmlrpc/__init__.pyc ./ top_level.txt SOURCES.txt dependency_links.txt requires.txt PKG-INFO Removing pies2overrides fixes the problem with flake8. I do not need pies2overrides anymore, so that is possible for me. Thanks for helping me, I will report this compatibility issue to pies.
Hi, Just adding my 2 cents as the maintainer of the pies package: Defining a builtins module in Python2 is entirely valid as it is not a reserved module in that version of Python. Python has a standard way to lookup it's version (sys.version) which should be used in all cases, and this is the first time I have ever seen that approach not followed. In fact there are two pull requests existing to fix this in the pyflakes source - but it appears to longer be actively maintained: https://github.com/pyflakes/pyflakes/pull/18/files https://github.com/pyflakes/pyflakes/pull/17/files If you take a second to look over the pies documentation it's reason for needing to define builtins should become clear: https://github.com/timothycrosley/pies The approach taking by pyflakes (if encouraged) would mean that any attempt to backport any module would not work.
Agreed, that's a valid use case for a module named like that.
pyflakes-0.7.3-4.fc20 has been submitted as an update for Fedora 20. https://admin.fedoraproject.org/updates/pyflakes-0.7.3-4.fc20
pyflakes-0.7.3-4.fc19 has been submitted as an update for Fedora 19. https://admin.fedoraproject.org/updates/pyflakes-0.7.3-4.fc19
Package pyflakes-0.7.3-4.fc19: * should fix your issue, * was pushed to the Fedora 19 testing repository, * should be available at your local mirror within two days. Update it with: # su -c 'yum update --enablerepo=updates-testing pyflakes-0.7.3-4.fc19' as soon as you are able to. Please go to the following url: https://admin.fedoraproject.org/updates/FEDORA-2013-23286/pyflakes-0.7.3-4.fc19 then log in and leave karma (feedback).
pyflakes-0.7.3-4.fc20 has been pushed to the Fedora 20 stable repository. If problems still persist, please make note of it in this bug report.
pyflakes-0.7.3-4.fc19 has been pushed to the Fedora 19 stable repository. If problems still persist, please make note of it in this bug report.