Skip to content

Commit

Permalink
Do not allow access to '__traceback__'.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephan-hof authored and Michael Howitz committed Nov 9, 2016
1 parent 8932611 commit deab046
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,22 @@ def no_exec():
"""


DISALLOW_TRACEBACK_ACCESS = """
try:
raise Exception()
except Exception as e:
tb = e.__traceback__
"""


@pytest.mark.parametrize(*compile)
def test_transformer__RestrictingNodeTransformer__visit_Attribute__6(compile):
code, errors = compile(DISALLOW_TRACEBACK_ACCESS)[:2]
assert code is None
assert errors[0] == 'Line 5: "__traceback__" is an invalid attribute ' \
'name because it starts with "_".'


@pytest.mark.skipif(sys.version_info < (3, 0),
reason="exec is a statement in Python 2")
@pytest.mark.parametrize(*compile)
Expand Down

0 comments on commit deab046

Please sign in to comment.