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

bpo-41631: Check that importing _ast returns the right module #21973

Closed
encukou wants to merge 4 commits into
python:masterpython/cpython:masterfrom
encukou:check-ast-module-def_masterencukou/cpython:check-ast-module-def_masterCopy head branch name to clipboard
Closed

bpo-41631: Check that importing _ast returns the right module #21973
encukou wants to merge 4 commits into
python:masterpython/cpython:masterfrom
encukou:check-ast-module-def_masterencukou/cpython:check-ast-module-def_masterCopy head branch name to clipboard

Conversation

@encukou

@encukou encukou commented Aug 26, 2020

Copy link
Copy Markdown
Member

Hopefully #21961 will be OK, but if not: here is a relatively minimal fix for bpo-41631, which basically makes compiling to/from AST fail gracefully (with a proper exception rather than a NULL without exception) if the _ast module has been tampered with.
For example, it looks like Mercurial's lazy-loading scheme replaces _astwith a proxy object; this will make AST unusable.

The second commit deals with a hack in pegen's tests – please review the commits separately, and see comments.

https://bugs.python.org/issue41631

@encukou

encukou commented Sep 8, 2020

Copy link
Copy Markdown
Member Author

@pablogsal, does this make sense for peg_generator? (Keeping in mind this would be a last-minute fix for 3.9, with a better solution hopefully coming in 3.10.)

@pablogsal

Copy link
Copy Markdown
Member

@pablogsal, does this make sense for peg_generator? (Keeping in mind this would be a last-minute fix for 3.9, with a better solution hopefully coming in 3.10.)

Yup, it does sense to me as a temporary solution 👍

Comment thread Tools/peg_generator/pegen/build.py Outdated
encukou and others added 2 commits September 9, 2020 10:38
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
The previous behavior didn't always segfault -- in fact, it usually
raised a SystemError as well. A segfault (or any other behavior,
depending on the module object imported as _ast) was still *possible*,
but for that level of detail people should see the bpo issue.
@vstinner

Copy link
Copy Markdown
Member

Thanks for the workaround. PR 21961 fix has been merged instead.

@vstinner vstinner closed this Sep 16, 2020
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

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