Skip to content

gh-159739: Fix reference and error handling in warnings - #159758

Merged
JelleZijlstra merged 4 commits into
python:mainfrom
jelle-openai:jelle/codex/gh-159739-warnings-errors
Oct 21, 2026
Merged

JelleZijlstra merged 4 commits into
python:mainfrom
jelle-openai:jelle/codex/gh-159739-warnings-errors

Conversation

@jelle-openai

@jelle-openai jelle-openai commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Do not release the borrowed skip_file_prefixes argument, and stop if
allocation of the fallback filename fails.

Backport to 3.15 and 3.14.

Do not release the borrowed skip_file_prefixes argument, and stop if
allocation of the fallback filename fails.

Backport to 3.15 and 3.14.
@JelleZijlstra

Copy link
Copy Markdown
Member

Verified this crash:

>>> class X(tuple): pass
... 
>>> warnings.warn("hi", skip_file_prefixes=X())
<python-input-11>:1: UserWarning: hi
Assertion failed: (!_Py_IsStaticImmortal(op)), function Py_DECREF_MORTAL, file pycore_object.h, line 412.
Abort trap: 6

@JelleZijlstra JelleZijlstra added needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 19, 2026
@gpshead gpshead self-assigned this Oct 19, 2026

@gpshead gpshead left a comment

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.

consider a regression test?

class T(tuple): pass
for _ in range(3):
    with self.module.catch_warnings(record=True):
        self.module.warn("msg", skip_file_prefixes=T())

@gpshead gpshead removed their assignment Oct 19, 2026
@JelleZijlstra
JelleZijlstra merged commit fab1405 into python:main Oct 21, 2026
56 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @jelle-openai for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @jelle-openai and @JelleZijlstra, I could not cleanly backport this to 3.14 due to a conflict.

Please backport manually with cherry_picker, see the devguide for more information.

cherry_picker fab1405da8c93429ab1a1d3d3e1779d15b7223a2 3.14

@bedevere-app

bedevere-app Bot commented Oct 21, 2026

Copy link
Copy Markdown

GH-160022 is a backport of this pull request to the 3.15 branch.

@bedevere-app

bedevere-app Bot commented Oct 21, 2026

Copy link
Copy Markdown

GH-160085 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 21, 2026
JelleZijlstra pushed a commit that referenced this pull request Oct 21, 2026
…9758) (#160022)

Do not release the borrowed skip_file_prefixes argument, and stop if
allocation of the fallback filename fails.
(cherry picked from commit fab1405)

Co-authored-by: Jelle Zijlstra <jelle@openai.com>
JelleZijlstra pushed a commit that referenced this pull request Oct 21, 2026
…9758) (#160085)

Do not release the borrowed skip_file_prefixes argument, and stop if
allocation of the fallback filename fails.

(cherry picked from commit fab1405)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants