A return statement between try and except makes decompilation fail to produce correct results.
$ python Python 3.11.1 (main, Sep 8 2025, 16:27:45) [GCC 8.3.0] on linux
def test():
try:
a = 1
except:
return False
return False
The pyc file generated by the code above can be decompiled correctly.
def test():
try:
return 1
except:
return False
return False
The pyc file generated by the code above can't be decompiled correctly.