Issue 3643: Add more checks to testcapi (original) (raw)

Issue3643

Created on 2008-08-22 01:41 by vstinner, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
testcapi_py26.patch vstinner,2008-08-22 01:41 Fix _test_thread_state() and raise_exception() and _testcapi module
testcapi_py30.patch vstinner,2008-08-22 01:44 Fix exception_print() of _testcapi module
Messages (9)
msg71714 - (view) Author: STINNER Victor (vstinner) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) Date: 2008-08-23 20:33
Fair enough. Fixed in r66000 (trunk) and r66001 (py3k).
History
Date User Action Args
2022-04-11 14:56:38 admin set github: 47893
2008-08-23 20:33:11 benjamin.peterson set status: open -> closedresolution: fixedmessages: + versions: + Python 2.6, Python 3.0, - Python 3.1, Python 2.7
2008-08-23 19:53:16 georg.brandl set priority: normal -> highnosy: + georg.brandlmessages: +
2008-08-23 18:31:52 vstinner set messages: +
2008-08-23 16:39:22 ajaksu2 set nosy: + ajaksu2
2008-08-22 19:11:34 benjamin.peterson set assignee: benjamin.petersonmessages: +
2008-08-22 09:33:29 pitrou set nosy: + pitroumessages: + versions: + Python 3.1, Python 2.7, - Python 2.6, Python 3.0
2008-08-22 08:50:37 vstinner set messages: +
2008-08-22 01:56:21 benjamin.peterson set priority: normalnosy: + benjamin.petersonmessages: +
2008-08-22 01:44:20 vstinner set files: + testcapi_py30.patchmessages: +
2008-08-22 01:41:22 vstinner create