8000 [3.13] gh-117482: Simplify the Fix For Builtin Types Slot Wrappers by ericsnowcurrently · Pull Request #121932 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.13] gh-117482: Simplify the Fix For Builtin Types Slot Wrappers #121932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
Next Next commit
Add some comments.
  • Loading branch information
ericsnowcurrently committed Jul 22, 2024
commit 8650cf117bd766901983bab0a2326e7c40054ee1
6 changes: 6 additions & 0 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -10867,6 +10867,8 @@ expect_manually_inherited(PyTypeObject *type, void **slot)
{
PyObject *typeobj = (PyObject *)type;
if (slot == (void *)&type->tp_init) {
/* This is a best-effort list of builtin exception types
that have their own tp_init function. */
if (typeobj != PyExc_BaseException
&& typeobj != PyExc_BaseExceptionGroup
&& typeobj != PyExc_ImportError
Expand All @@ -10881,13 +10883,17 @@ expect_manually_inherited(PyTypeObject *type, void **slot)
}
}
else if (slot == (void *)&type->tp_str) {
/* This is a best-effort list of builtin exception types
that have their own tp_str function. */
if (typeobj == PyExc_AttributeError || typeobj == PyExc_NameError) {
return 1;
}
}
else if (slot == (void *)&type->tp_getattr
|| slot == (void *)&type->tp_getattro)
{
/* This is a best-effort list of builtin types
that have their own tp_getattr function. */
if (typeobj == PyExc_BaseException
|| type == &PyBool_Type
|| type == &PyByteArray_Type
Expand Down
0