Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0a6996d

Browse files
committed
Merge 3.5 (fix raise)
2 parents 989df09 + eec9331 commit 0a6996d

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

Lib/test/test_threading.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,24 @@ def run():
10431043
self.assertEqual(out, b'')
10441044
self.assertNotIn("Unhandled exception", err.decode())
10451045

1046+
def test_bare_raise_in_brand_new_thread(self):
1047+
def bare_raise():
1048+
raise
1049+
1050+
class Issue27558(threading.Thread):
1051+
exc = None
1052+
1053+
def run(self):
1054+
try:
1055+
bare_raise()
1056+
except Exception as exc:
1057+
self.exc = exc
1058+
1059+
thread = Issue27558()
1060+
thread.start()
1061+
thread.join()
1062+
self.assertIsNotNone(thread.exc)
1063+
self.assertIsInstance(thread.exc, RuntimeError)
10461064

10471065
class TimerTests(BaseTestCase):
10481066

Misc/NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ What's New in Python 3.6.0 beta 1
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #27558: Fix a SystemError in the implementation of "raise" statement.
14+
In a brand new thread, raise a RuntimeError since there is no active
15+
exception to reraise. Patch written by Xiang Zhang.
16+
1317
Library
1418
-------
1519

1620
- Issue #9998: On Linux, ctypes.util.find_library now looks in LD_LIBRARY_PATH
1721
for shared libraries.
1822

23+
1924
What's New in Python 3.6.0 alpha 4
2025
==================================
2126

Python/ceval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4154,7 +4154,7 @@ do_raise(PyObject *exc, PyObject *cause)
41544154
type = tstate->exc_type;
41554155
value = tstate->exc_value;
41564156
tb = tstate->exc_traceback;
4157-
if (type == Py_None) {
4157+
if (type == Py_None || type == NULL) {
41584158
PyErr_SetString(PyExc_RuntimeError,
41594159
"No active exception to reraise");
41604160
return 0;

0 commit comments

Comments
 (0)