summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-08-18 16:14:15 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-08-18 16:14:15 (GMT)
commit0a6996d87d19a524c2a11dd315d96d12083c47d4 (patch)
tree291cd0aa99adb9e0800d34393a75ebde33eaa595
parent989df09db23f2e7588a9e88c6d05611d3c411582 (diff)
parenteec9331b207cf7def6f04156d00a8479d1630dd3 (diff)
downloadcpython-0a6996d87d19a524c2a11dd315d96d12083c47d4.zip
cpython-0a6996d87d19a524c2a11dd315d96d12083c47d4.tar.gz
cpython-0a6996d87d19a524c2a11dd315d96d12083c47d4.tar.bz2
Merge 3.5 (fix raise)
-rw-r--r--Lib/test/test_threading.py18
-rw-r--r--Misc/NEWS5
-rw-r--r--Python/ceval.c2
3 files changed, 24 insertions, 1 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index a4aa49f..845e7d4 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -1043,6 +1043,24 @@ class ThreadingExceptionTests(BaseTestCase):
self.assertEqual(out, b'')
self.assertNotIn("Unhandled exception", err.decode())
+ def test_bare_raise_in_brand_new_thread(self):
+ def bare_raise():
+ raise
+
+ class Issue27558(threading.Thread):
+ exc = None
+
+ def run(self):
+ try:
+ bare_raise()
+ except Exception as exc:
+ self.exc = exc
+
+ thread = Issue27558()
+ thread.start()
+ thread.join()
+ self.assertIsNotNone(thread.exc)
+ self.assertIsInstance(thread.exc, RuntimeError)
class TimerTests(BaseTestCase):
diff --git a/Misc/NEWS b/Misc/NEWS
index 2246f22..2cd61e6 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,12 +10,17 @@ What's New in Python 3.6.0 beta 1
Core and Builtins
-----------------
+- Issue #27558: Fix a SystemError in the implementation of "raise" statement.
+ In a brand new thread, raise a RuntimeError since there is no active
+ exception to reraise. Patch written by Xiang Zhang.
+
Library
-------
- Issue #9998: On Linux, ctypes.util.find_library now looks in LD_LIBRARY_PATH
for shared libraries.
+
What's New in Python 3.6.0 alpha 4
==================================
diff --git a/Python/ceval.c b/Python/ceval.c
index 07ac167..8e7d5c2 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -4154,7 +4154,7 @@ do_raise(PyObject *exc, PyObject *cause)
type = tstate->exc_type;
value = tstate->exc_value;
tb = tstate->exc_traceback;
- if (type == Py_None) {
+ if (type == Py_None || type == NULL) {
PyErr_SetString(PyExc_RuntimeError,
"No active exception to reraise");
return 0;