Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash under python2.7 #654

Closed
e3kr opened this issue Sep 22, 2021 · 5 comments
Closed

crash under python2.7 #654

e3kr opened this issue Sep 22, 2021 · 5 comments
Labels

Comments

@e3kr
Copy link

e3kr commented Sep 22, 2021

Running pyflakes 2.3.1 on this file

# fail.py 
import unused

def fail(**unused):
    pass

results in

$ pyflakes fail.py 
Traceback (most recent call last):
  File "/home/kr/pyflakes/.env/bin/pyflakes", line 8, in <module>
    sys.exit(main())
  File "/home/kr/pyflakes/.env/lib/python2.7/site-packages/pyflakes/api.py", line 210, in main
    warnings = checkRecursive(args, reporter)
  File "/home/kr/pyflakes/.env/lib/python2.7/site-packages/pyflakes/api.py", line 155, in checkRecursive
    warnings += checkPath(sourcePath, reporter)
  File "/home/kr/pyflakes/.env/lib/python2.7/site-packages/pyflakes/api.py", line 99, in checkPath
    return check(codestr, filename, reporter)
  File "/home/kr/pyflakes/.env/lib/python2.7/site-packages/pyflakes/api.py", line 74, in check
    w = checker.Checker(tree, file_tokens=file_tokens, filename=filename)
  File "/home/kr/pyflakes/.env/lib/python2.7/site-packages/pyflakes/checker.py", line 916, in __init__
    self.checkDeadScopes()
  File "/home/kr/pyflakes/.env/lib/python2.7/site-packages/pyflakes/checker.py", line 1041, in checkDeadScopes
    self.report(messg, node, value.name, value.source)
  File "/home/kr/pyflakes/.env/lib/python2.7/site-packages/pyflakes/checker.py", line 1047, in report
    self.messages.append(messageClass(self.filename, *args, **kwargs))
  File "/home/kr/pyflakes/.env/lib/python2.7/site-packages/pyflakes/messages.py", line 32, in __init__
    Message.__init__(self, filename, loc)
  File "/home/kr/pyflakes/.env/lib/python2.7/site-packages/pyflakes/messages.py", line 12, in __init__
    self.lineno = loc.lineno
AttributeError: 'arguments' object has no attribute 'lineno'

while it runs properly under python3:

$ pyflakes fail.py 
fail.py:2:1 'unused' imported but unused
fail.py:4:12 redefinition of unused 'unused' from line 2

Under 2.7 it also fails on

# fail.py 
import unused

def fail(*unused):
    pass

(difference is in *unused vs **unused)

When the last star is removed it starts working again on python 2.7:

$ cat fail.py 
# fail.py 
import unused

def fail(unused):
    pass
$ pyflakes fail.py 
fail.py:2:1 'unused' imported but unused
fail.py:4:10 redefinition of unused 'unused' from line 2

import-ed symbols are somewhat different, as the following runs silently on both python2 and python3:

# fail.py 
unused = True

def fail(**unused):
    pass
@asottile asottile added the bug label Sep 22, 2021
@asottile
Copy link
Member

I think it's probably time we stop supporting python 2

@e3kr
Copy link
Author

e3kr commented Sep 22, 2021

I was afraid of this response :(

@asottile
Copy link
Member

it's almost 2 years past end of life, it's time to move on

@hugovk
Copy link
Contributor

hugovk commented Dec 27, 2021

#660 has been merged, ending support for Python 2.7.

@sigmavirus24
Copy link
Member

@e3kr older versions of pyflakes will still support Python 2.7. That language is not evolving and so pyflakes will continue to work, you likely don't need any of the new features of pyflakes that are all related to new language features in newer versions of 3.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants