Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-146102: Catch PyErr_NewException() failure in zlib#151342

Closed
vstinner wants to merge 1 commit into
python:mainpython/cpython:mainfrom
vstinner:zlibvstinner/cpython:zlibCopy head branch name to clipboard
Closed

gh-146102: Catch PyErr_NewException() failure in zlib#151342
vstinner wants to merge 1 commit into
python:mainpython/cpython:mainfrom
vstinner:zlibvstinner/cpython:zlibCopy head branch name to clipboard

Conversation

@vstinner

@vstinner vstinner commented Jun 11, 2026

Copy link
Copy Markdown
Member

@vstinner

Copy link
Copy Markdown
Member Author

Comment thread Modules/zlibmodule.c
if (state->ZlibError == NULL) {
return -1;
}
if (PyModule_AddObjectRef(mod, "error", state->ZlibError) < 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This isn't strictly necessary, PyModule_AddObjectRef will return -1 if it's NULL. Looking at other modules, they also follow this pattern.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh you're right! I checked PyModule_AddObjectRef() documentation and it's well documented:

To be convenient, the function accepts NULL value with an exception
set. In this case, return -1 and just leave the raised exception
unchanged.

@vstinner

Copy link
Copy Markdown
Member Author

This change is not needed. I close the PR.

@vstinner vstinner closed this Jun 11, 2026
@vstinner vstinner deleted the zlib branch June 11, 2026 14:54
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.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.