Closed sole6 closed 3 years ago
fix_except returns FP even when the code contains try..except according to Python 3 specification
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!')
Description
fix_except returns FP even when the code contains try..except according to Python 3 specification
Details
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
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