Skip to content

Commit

Permalink
Add test for frame.f_locals
Browse files Browse the repository at this point in the history
  • Loading branch information
jondy committed Mar 31, 2018
1 parent 7c0eebb commit 2732664
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/examples/testmod/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
from traceback import print_exc
print_exc()

# Check original func can not be got from exception frame
try:
queens.test_exception()
except Exception:
import inspect
for exc_tb in inspect.trace():
frame = exc_tb[0]
if frame.f_locals.get('func'):
print('Got original func from frame.f_locals')

# Access original func_code will crash: Segmentation fault
# print(dis.dis(main.orig_func))
# print(dis.dis(Queens.solve.orig_func))
4 changes: 2 additions & 2 deletions tests/system-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,9 @@ check_file_content $PROPATH/dist/result.log 'Found 92 solutions'
check_file_content $PROPATH/dist/result.log '__wraparmor__ can not be called out of decorator'
check_file_content $PROPATH/dist/result.log 'The value of __file__ is OK'
check_file_content $PROPATH/dist/result.log '<frozen queens>'
# check_file_content $PROPATH/dist/result.log 'Segmentation fault' not
check_file_content $PROPATH/dist/result.log 'Got original func from frame.f_locals' not

csih_inform "Case T-1.3: obfuscate module with cwrap mode"
csih_inform "Case T-1.3: obfuscate module with auto-wrap mode"
PROPATH=projects/testmod_auto_wrap
$PYARMOR init --src=examples/py2exe --entry=queens.py $PROPATH >result.log 2>&1
$PYARMOR config --obf-code-mode=wrap --disable-restrict-mode=1 \
Expand Down

0 comments on commit 2732664

Please sign in to comment.