Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 15 additions & 0 deletions Lib/test/test_threading_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,21 @@ def test_threading_local_clear_race(self):

_testcapi.join_temporary_c_thread()

@support.cpython_only
def test_error(self):
class Loop(self._local):
attr = 1

# Trick the "if name == '__dict__':" test of __setattr__()
# to always be true
class NameCompareTrue:
def __eq__(self, other):
return True

loop = Loop()
with self.assertRaisesRegex(AttributeError, 'Loop.*read-only'):
loop.__setattr__(NameCompareTrue(), 2)


class ThreadLocalTest(unittest.TestCase, BaseLocalTest):
_local = _thread._local
Expand Down
2 changes: 1 addition & 1 deletion Modules/_threadmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1624,7 +1624,7 @@ local_setattro(localobject *self, PyObject *name, PyObject *v)
}
if (r == 1) {
PyErr_Format(PyExc_AttributeError,
"'%.100s' object attribute '%U' is read-only",
"'%.100s' object attribute %R is read-only",
Py_TYPE(self)->tp_name, name);
goto err;
}
Expand Down
Loading