Bug 1039706

Summary: [abrt] pyflakes-0.7.2-1.fc19: checker.py:722:LAMBDA:AttributeError: 'arguments' object has no attribute 'kwonlyargs'
Product: [Fedora] Fedora Reporter: Bengt Lüers <Bengt.Lueers>
Component: pyflakesAssignee: Ville Skyttä <ville.skytta>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 19CC: Bengt.Lueers, jeff, timothy.crosley, ville.skytta
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
URL: https://retrace.fedoraproject.org/faf/reports/bthash/34e60168f152c9177f13df2e2591d9eeeb33a0d1
Whiteboard: abrt_hash:ad0e2d2a17fb2789a2af624c4b0d800ca3543bce
Fixed In Version: pyflakes-0.7.3-4.fc19 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-12-21 02:19:44 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
File: backtrace
none
File: environ
none
Workaround patch none

Description Bengt Lüers 2013-12-09 20:33:43 UTC
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: []

Comment 1 Bengt Lüers 2013-12-09 20:33:47 UTC
Created attachment 834520 [details]
File: backtrace

Comment 2 Bengt Lüers 2013-12-09 20:33:51 UTC
Created attachment 834521 [details]
File: environ

Comment 3 Ville Skyttä 2013-12-10 13:52:28 UTC
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?

Comment 4 Bengt Lüers 2013-12-10 14:11:26 UTC
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.

Comment 5 Ville Skyttä 2013-12-10 14:24:22 UTC
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.

Comment 6 Bengt Lüers 2013-12-10 22:22:06 UTC
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.

Comment 7 timothycrosley 2013-12-10 22:56:15 UTC
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.

Comment 8 Ville Skyttä 2013-12-11 19:27:48 UTC
Agreed, that's a valid use case for a module named like that.

Comment 9 Fedora Update System 2013-12-11 19:35:40 UTC
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

Comment 10 Fedora Update System 2013-12-11 19:37:20 UTC
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

Comment 11 Fedora Update System 2013-12-13 05:02:43 UTC
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).

Comment 12 Fedora Update System 2013-12-21 02:16:37 UTC
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.

Comment 13 Fedora Update System 2013-12-21 02:19:44 UTC
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.