msg71714 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2008-08-22 01:41 |
test_thread_state() doesn't check that the argument is a function and doesn't check function call result and so the exception is catched later: Non callable argument: import _testcapi _testcapi._test_thread_state(10) # no exception raise here import gc # exception raised too late! => TypeError: 'int' object is not callable Callback error: import _testcapi def err(): raise ValueError("xxx") _testcapi._test_thread_state(err) # no exception raise here import gc # exception raised too late! => ValueError: xxx So I wrote a patch which fixes that but also raise_exception() which have to check that the argument is an exception class. |
|
|
msg71715 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2008-08-22 01:44 |
Python 3.0 has an new function which requires an extra patch: exception_print() have to check that the argument is an exception instance: >>> import _testcapi >>> _testcapi.exception_print(10) Erreur de segmentation (core dumped) |
|
|
msg71716 - (view) |
Author: Benjamin Peterson (benjamin.peterson) *  |
Date: 2008-08-22 01:56 |
Your patches are pretty harmless, but this module is just for testing purposes. |
|
|
msg71730 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2008-08-22 08:50 |
@benjamin.peterson: I know but the module (installed in CPython default installation) is for testing purpose only, but invalid uses of its method would lead to inconsistent CPython internal state and that's bad :-) If you tried to say that such issue is not critical: yes, it's just a suggestion to improve CPython ;-) |
|
|
msg71735 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2008-08-22 09:33 |
Unless someone thinks it's somehow release-critical, I'm retargetting this to 2.7/3.1. |
|
|
msg71770 - (view) |
Author: Benjamin Peterson (benjamin.peterson) *  |
Date: 2008-08-22 19:11 |
Ok. I'll apply your patches when we get to 2.7. Do ping me if a forget, though. |
|
|
msg71808 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2008-08-23 18:31 |
@pitrou: This issue is not critical. It's not a bug, it's an enhancement since _testcapi :-) |
|
|
msg71810 - (view) |
Author: Georg Brandl (georg.brandl) *  |
Date: 2008-08-23 19:53 |
Still, _testcapi is built even for non-debug builds, so it is a gratuitous way for bad code to crash or internally invalidate a Python interpreter, so this should be treated like a bugfix. |
|
|
msg71814 - (view) |
Author: Benjamin Peterson (benjamin.peterson) *  |
Date: 2008-08-23 20:33 |
Fair enough. Fixed in r66000 (trunk) and r66001 (py3k). |
|
|