amyreese / fissix

backport of lib2to3, with enhancements
Other
45 stars 22 forks source link

FP in fix_except #37

Closed sole6 closed 3 years ago

sole6 commented 3 years ago

Description

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

Details

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!')