Skip to content

bpo-46449: Fix refcount of deepfrozen code #30984

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

Closed
wants to merge 1 commit into from

Conversation

tiran
Copy link
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]>
@@ -1321,7 +1321,7 @@ unmarshal_frozen_code(struct frozen_info *info)
if (info->get_code) {
PyObject *code = info->get_code();
assert(code != NULL);
return code;
return Py_NewRef(code);
Copy link
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
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