Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Lib/test/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1954,6 +1954,24 @@ def test_exec_set_nomemory_hang(self):
self.assertGreater(len(output), 0) # At minimum, should not hang
self.assertIn(b"MemoryError", output)

Comment thread
brijkapadia marked this conversation as resolved.
def test_data_race(self):
Comment thread
brijkapadia marked this conversation as resolved.
Outdated
from threading import Thread
import copy

E = Exception()

def func():
for i in range(100):
setattr(E, 'x', i)
copy.copy(E)

threads = [Thread(target=func) for _ in range(4)]
Comment thread
brijkapadia marked this conversation as resolved.
Outdated

for t in threads:
t.start()

for t in threads:
t.join()

class NameErrorTests(unittest.TestCase):
def test_name_error_has_name(self):
Expand Down
6 changes: 3 additions & 3 deletions Objects/clinic/exceptions.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Objects/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,15 @@ BaseException___reduce___impl(PyBaseExceptionObject *self)
*/

/*[clinic input]
@critical_section
@critical_section self state
Comment thread
brijkapadia marked this conversation as resolved.
Outdated
BaseException.__setstate__
state: object
/
[clinic start generated code]*/

static PyObject *
BaseException___setstate___impl(PyBaseExceptionObject *self, PyObject *state)
/*[clinic end generated code: output=f3834889950453ab input=5524b61cfe9b9856]*/
/*[clinic end generated code: output=f3834889950453ab input=2ddc941f42fc5bf6]*/
{
PyObject *d_key, *d_value;
Py_ssize_t i = 0;
Expand Down
Loading