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

FP in fix_except #37

Closed
sole6 opened this issue Mar 15, 2021 · 0 comments · Fixed by #40 · May be fixed by #38
Closed

FP in fix_except #37

sole6 opened this issue Mar 15, 2021 · 0 comments · Fixed by #40 · May be fixed by #38

Comments

@sole6
Copy link

sole6 commented Mar 15, 2021

Description

fix_except returns FP even when the code contains try..except according to Python 3 specification

Details

  • OS: Win10
  • Python version: 3.8
  • fissix version: 20.8.0
  • Can you repro on master? Yes
  • Can you repro in a clean virtualenv? yes

After looking into the issue, i think the problem is with the transform function in fix_except, where it only looks for the length of the except clause.
https://github.com/jreese/fissix/blob/main/fissix/fixes/fix_except.py

if len(except_clause.children) == 4:
                (E, comma, N) = except_clause.children[1:4]
                comma.replace(Name("as", prefix=" "))
                changed = True

A fix for this can be checking if there is a command being used.

Reproduction code:

Taken from https://docs.python.org/3/tutorial/errors.html

def test():    
    try:
        raise NameError('HiThere')
    except Exception as e:
        print('An exception flew by!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant