Visitar URL original
gh-118362: Fix thread safety around lookups from the type cache in the face of concurrent mutators by DinoV · Pull Request #118454 · python/cpython · GitHub
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
Prev Previous commit
Handle failure to create dict, fix formatting, remove extra pyerr_occ…
…urred
  • Loading branch information
DinoV committed May 3, 2024
commit 179dcd9f8ed41230faa7311b2d21dcb2dba6ae43
2 changes: 1 addition & 1 deletion Include/internal/pycore_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ extern PyObject *_PyType_NewManagedObject(PyTypeObject *type);
extern PyTypeObject* _PyType_CalculateMetaclass(PyTypeObject *, PyObject *);
extern PyObject* _PyType_GetDocFromInternalDoc(const char *, const char *);
extern PyObject* _PyType_GetTextSignatureFromInternalDoc(const char *, const char *, int);
extern int _PyObject_SetAttributeErrorContext(PyObject* v, PyObject* name);
extern int _PyObject_SetAttributeErrorContext(PyObject *v, PyObject* name);

void _PyObject_InitInlineValues(PyObject *obj, PyTypeObject *tp);
extern int _PyObject_StoreInstanceAttribute(PyObject *obj,
Expand Down
7 changes: 3 additions & 4 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -5033,10 +5033,6 @@ find_name_in_mro(PyTypeObject *type, PyObject *name, int *error)
if (res != NULL) {
break;
}
if (PyErr_Occurred()) {
*error = -1;
goto done;
}
}
*error = 0;
done:
Expand Down Expand Up @@ -5450,6 +5446,9 @@ type_setattro(PyObject *self, PyObject *name, PyObject *value)
dict = type->tp_dict = PyDict_New();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to handle the case where PyDict_New() returns NULL.

}
END_TYPE_LOCK();
if (dict == NULL) {
return -1;
}
}

// We don't want any re-entrancy between when we update the dict
Expand Down