Skip to content

gh-145783: Propagate errors raised in NEW_TYPE_COMMENT #145784

Merged
pablogsal merged 2 commits intopython:mainfrom
StanFromIreland:raise-error-parser
Mar 13, 2026
Merged

gh-145783: Propagate errors raised in NEW_TYPE_COMMENT #145784
pablogsal merged 2 commits intopython:mainfrom
StanFromIreland:raise-error-parser

Conversation

@StanFromIreland
Copy link
Member

@StanFromIreland StanFromIreland commented Mar 10, 2026

_testcapi = import_helper.import_module('_testcapi')
flags = 0x0800 | 0x1000 # PyCF_IGNORE_COOKIE | PyCF_TYPE_COMMENTS
with self.assertRaises(UnicodeDecodeError):
_testcapi.Py_CompileStringExFlags(
Copy link
Member

Choose a reason for hiding this comment

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

Why does this need _testcapi? Was the error not reproducible with a direct call to e.g. compile()?

Copy link
Member Author

Choose a reason for hiding this comment

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

You can't pass PyCF_IGNORE_COOKIE to compile() (or any other Python API).

>>> compile(b'a=1 # type: \x80', '<test>', 'single', flags=0x0800|0x1000)                                                                       
ValueError: compile(): unrecognised flags

Since this is the function used in the fuzzer, (I hope) it may be useful for future issues found by it.

@StanFromIreland
Copy link
Member Author

The fuzzer likes this one so much it just "found" it again 🙃

@pablogsal pablogsal merged commit e1c2246 into python:main Mar 13, 2026
106 of 107 checks passed
@pablogsal
Copy link
Member

Great job @StanFromIreland 👏

@pablogsal pablogsal added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Mar 13, 2026
@miss-islington-app
Copy link

Thanks @StanFromIreland for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks @StanFromIreland for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @StanFromIreland and @pablogsal, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker e1c224624ae601c464acbf173e2aa90fa980ab45 3.14

@miss-islington-app
Copy link

Sorry, @StanFromIreland and @pablogsal, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker e1c224624ae601c464acbf173e2aa90fa980ab45 3.13

@pablogsal
Copy link
Member

@StanFromIreland can you do the backports when you have some time?

@StanFromIreland StanFromIreland deleted the raise-error-parser branch March 13, 2026 15:55
@bedevere-app
Copy link

bedevere-app bot commented Mar 13, 2026

GH-145926 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 Mar 13, 2026
StanFromIreland added a commit to StanFromIreland/cpython that referenced this pull request Mar 13, 2026
…pythonGH-145784)

(cherry picked from commit e1c2246)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
StanFromIreland added a commit to StanFromIreland/cpython that referenced this pull request Mar 13, 2026
…pythonGH-145784)

(cherry picked from commit e1c2246)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Mar 13, 2026

GH-145927 is a backport of this pull request to the 3.13 branch.

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