diff options
author | Jeffrey Yasskin <jyasskin@gmail.com> | 2010-05-13 18:31:05 (GMT) |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@gmail.com> | 2010-05-13 18:31:05 (GMT) |
commit | 8e0bdfd1d473ddffaf3501768678f8a970019da8 (patch) | |
tree | df31716c768c6512c72f40819f0cc752c7e742f4 /Lib/test/test_capi.py | |
parent | f55621115cb2b73f60e7396cbade18a89a80d989 (diff) | |
download | cpython-8e0bdfd1d473ddffaf3501768678f8a970019da8.zip cpython-8e0bdfd1d473ddffaf3501768678f8a970019da8.tar.gz cpython-8e0bdfd1d473ddffaf3501768678f8a970019da8.tar.bz2 |
Make PyErr_Occurred return NULL if there is no current thread. Previously it
would Py_FatalError, which called PyErr_Occurred, resulting in a semi-infinite
recursion.
Fixes issue 3605.
Diffstat (limited to 'Lib/test/test_capi.py')
-rw-r--r-- | Lib/test/test_capi.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py index 29f7a71..7a6870d 100644 --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -2,9 +2,10 @@ # these are all functions _testcapi exports whose name begins with 'test_'. from __future__ import with_statement +import random +import subprocess import sys import time -import random import unittest from test import support try: @@ -35,6 +36,19 @@ class CAPITest(unittest.TestCase): self.assertEqual(testfunction.attribute, "test") self.assertRaises(AttributeError, setattr, inst.testfunction, "attribute", "test") + def test_no_FatalError_infinite_loop(self): + p = subprocess.Popen([sys.executable, "-c", + 'import _testcapi;' + '_testcapi.crash_no_current_thread()'], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + (out, err) = p.communicate() + self.assertEqual(out, b'') + # This used to cause an infinite loop. + self.assertEqual(err, + b'Fatal Python error:' + b' PyThreadState_Get: no current thread\n') + @unittest.skipUnless(threading, 'Threading required for this test.') class TestPendingCalls(unittest.TestCase): |