Commit cfa7e896 authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

nested_except_trace: document about another problem

parent c0302a44
...@@ -11,7 +11,7 @@ class FixNestedExceptTrace(BaseFix): ...@@ -11,7 +11,7 @@ class FixNestedExceptTrace(BaseFix):
"""This fixer detects scope bugs which can occur due to nested except clauses """This fixer detects scope bugs which can occur due to nested except clauses
which use the same variable name. which use the same variable name.
Try the following code yourself in Python 2 and Python 3... Try the following two snippets yourself in Python 2 and Python 3...
try: try:
raise Exception("foo") raise Exception("foo")
...@@ -21,6 +21,17 @@ class FixNestedExceptTrace(BaseFix): ...@@ -21,6 +21,17 @@ class FixNestedExceptTrace(BaseFix):
except Exception as e: except Exception as e:
print(e) print(e)
print(e) print(e)
---
try:
raise Exception("foo")
except Exception as e:
try:
raise Exception("bar")
except Exception as e:
print(e)
raise
""" """
# https://github.com/python/cpython/blob/3549ca313a6103a3adb281ef3a849298b7d7f72c/Lib/lib2to3/fixes/fix_except.py#L39-L45 # https://github.com/python/cpython/blob/3549ca313a6103a3adb281ef3a849298b7d7f72c/Lib/lib2to3/fixes/fix_except.py#L39-L45
PATTERN = """ PATTERN = """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment