Skip to content

bpo-46449: Fix refcount of deepfrozen code#30984

Closed
tiran wants to merge 1 commit intopython:mainfrom
tiran:bpo-46449-code-ref
Closed

bpo-46449: Fix refcount of deepfrozen code#30984
tiran wants to merge 1 commit intopython:mainfrom
tiran:bpo-46449-code-ref

Conversation

@tiran
Copy link
Copy Markdown
Member

@tiran tiran commented Jan 28, 2022

get_code() returns a borrowed reference. unmarshal_frozen_code is
expected to return a strong reference.

Signed-off-by: Christian Heimes [email protected]

https://bugs.python.org/issue46449

get_code() returns a borrowed reference. unmarshal_frozen_code is
expected to return a strong reference.

Signed-off-by: Christian Heimes <[email protected]>
Comment thread Python/import.c
PyObject *code = info->get_code();
assert(code != NULL);
return code;
return Py_NewRef(code);
Copy link
Copy Markdown
Member

@vstinner vstinner Jan 28, 2022

Choose a reason for hiding this comment

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

The get_code() function was added to the _frozen structure in Python 3.11. New C API functions must no longer return borrowed references, but strong references: https://devguide.python.org/c-api/#public-c-api

Would it be possible to change the generated code to return strong references instead? I don't understand how deepfreeze generates its "get_code()" functions.

cc @kumaraditya303

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.

@tiran tiran closed this Jan 28, 2022
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.

5 participants