Don't make the assumption that the 'name' argument is a string. Use
repr() to format the 'name' argument instead.
_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
}
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;
}