Skip to content

Commit

Permalink
GH-90699: use statically allocated strings in typeobject.c (gh-93751)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaraditya303 authored Jun 12, 2022
1 parent ae1ca74 commit 9331087
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Include/internal/pycore_global_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(__delete__)
STRUCT_FOR_ID(__delitem__)
STRUCT_FOR_ID(__dict__)
STRUCT_FOR_ID(__dictoffset__)
STRUCT_FOR_ID(__dir__)
STRUCT_FOR_ID(__divmod__)
STRUCT_FOR_ID(__doc__)
Expand Down Expand Up @@ -206,6 +207,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(__typing_subst__)
STRUCT_FOR_ID(__typing_unpacked_tuple_args__)
STRUCT_FOR_ID(__warningregistry__)
STRUCT_FOR_ID(__weaklistoffset__)
STRUCT_FOR_ID(__weakref__)
STRUCT_FOR_ID(__xor__)
STRUCT_FOR_ID(_abc_impl)
Expand Down
2 changes: 2 additions & 0 deletions Include/internal/pycore_runtime_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ extern "C" {
INIT_ID(__delete__), \
INIT_ID(__delitem__), \
INIT_ID(__dict__), \
INIT_ID(__dictoffset__), \
INIT_ID(__dir__), \
INIT_ID(__divmod__), \
INIT_ID(__doc__), \
Expand Down Expand Up @@ -828,6 +829,7 @@ extern "C" {
INIT_ID(__typing_subst__), \
INIT_ID(__typing_unpacked_tuple_args__), \
INIT_ID(__warningregistry__), \
INIT_ID(__weaklistoffset__), \
INIT_ID(__weakref__), \
INIT_ID(__xor__), \
INIT_ID(_abc_impl), \
Expand Down
4 changes: 2 additions & 2 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -3637,13 +3637,13 @@ PyType_FromMetaclass(PyTypeObject *metaclass, PyObject *module,

if (weaklistoffset) {
type->tp_weaklistoffset = weaklistoffset;
if (PyDict_DelItemString((PyObject *)type->tp_dict, "__weaklistoffset__") < 0) {
if (PyDict_DelItem((PyObject *)type->tp_dict, &_Py_ID(__weaklistoffset__)) < 0) {
goto finally;
}
}
if (dictoffset) {
type->tp_dictoffset = dictoffset;
if (PyDict_DelItemString((PyObject *)type->tp_dict, "__dictoffset__") < 0) {
if (PyDict_DelItem((PyObject *)type->tp_dict, &_Py_ID(__dictoffset__)) < 0) {
goto finally;
}
}
Expand Down

0 comments on commit 9331087

Please sign in to comment.