Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fixes a crash of :class:`types.SimpleNamespace` on free-threading builds,
Comment thread
sobolevn marked this conversation as resolved.
Outdated
when several threads were calling its :meth:`~object.__repr__` method at the
same time.
5 changes: 2 additions & 3 deletions Objects/namespaceobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ namespace_repr(PyObject *ns)
if (PyUnicode_Check(key) && PyUnicode_GET_LENGTH(key) > 0) {
PyObject *value, *item;

value = PyDict_GetItemWithError(d, key);
if (value != NULL) {
if (PyDict_GetItemRef(d, key, &value) == 1) {
Comment thread
sobolevn marked this conversation as resolved.
Outdated
item = PyUnicode_FromFormat("%U=%R", key, value);
Comment thread
sobolevn marked this conversation as resolved.
if (item == NULL) {
loop_error = 1;
Expand All @@ -135,7 +134,7 @@ namespace_repr(PyObject *ns)
Py_DECREF(item);
}
}
else if (PyErr_Occurred()) {
else {
Comment thread
sobolevn marked this conversation as resolved.
Outdated
loop_error = 1;
}
}
Expand Down
Loading