2to3 fixer to convert try .. except .. block
- by Sridhar Ratnakumar
I have a Python2 project with lots of try .. except .. blocks like this:
try:
[...]
except SomeException, e:
# do something with `e`
To port them all to Python 3 (and still have the code run Python =2.6), I have to manually change each and every one of them to the following:
try:
[...]
except SomeException, e:
_, e, _ = sys.exc_info()
# do something with `e`
Can this be automated using 2to3? If so, how?