Skip to content

bpo-44562: Use PyType_GenericAlloc in Py_GenericAlias #27021

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
merged 2 commits into from
Jul 5, 2021

Conversation

pablogsal
Copy link
Member

@pablogsal pablogsal commented Jul 4, 2021

@@ -646,11 +646,11 @@ PyTypeObject Py_GenericAliasType = {
PyObject *
Py_GenericAlias(PyObject *origin, PyObject *args)
{
gaobject *alias = PyObject_GC_New(gaobject, &Py_GenericAliasType);
gaobject *alias = (gaobject*) PyType_GenericAlloc(
Copy link
Member

Choose a reason for hiding this comment

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

PyType_GenericAlloc() calls _PyObject_GC_Malloc() instead of PyObject_GC_New().

Copy link
Member Author

Choose a reason for hiding this comment

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

_PyObject_GC_New calls _PyObject_GC_Malloc + _PyObject_Init, which PyType_GenericAlloc also calls. What I am missing?

Copy link
Member

Choose a reason for hiding this comment

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

All right then.

Please fix also ga_new().

Copy link
Member

Choose a reason for hiding this comment

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

ga_new doesn't seem to need the fix. It uses tp_alloc which is set to PyType_GenericAlloc .

@@ -646,11 +646,11 @@ PyTypeObject Py_GenericAliasType = {
PyObject *
Py_GenericAlias(PyObject *origin, PyObject *args)
{
gaobject *alias = PyObject_GC_New(gaobject, &Py_GenericAliasType);
gaobject *alias = (gaobject*) PyType_GenericAlloc(
Copy link
Member

Choose a reason for hiding this comment

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

All right then.

Please fix also ga_new().

@miss-islington
Copy link
Contributor

Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 5, 2021
* bpo-44562: Use PyType_GenericAlloc in Py_GenericAlias

* Update Objects/genericaliasobject.c

Co-authored-by: Serhiy Storchaka <[email protected]>

Co-authored-by: Serhiy Storchaka <[email protected]>
(cherry picked from commit b324c4c)

Co-authored-by: Pablo Galindo <[email protected]>
@bedevere-bot
Copy link

GH-27031 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Jul 5, 2021
miss-islington added a commit that referenced this pull request Jul 5, 2021
* bpo-44562: Use PyType_GenericAlloc in Py_GenericAlias

* Update Objects/genericaliasobject.c

Co-authored-by: Serhiy Storchaka <[email protected]>

Co-authored-by: Serhiy Storchaka <[email protected]>
(cherry picked from commit b324c4c)

Co-authored-by: Pablo Galindo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants