Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Fix #13881: Add plugin to disallow bytearray as filename in compile()#14173

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
vidhyavijayan3 wants to merge3 commits intopython:main
base:main
Choose a base branch
Loading
fromvidhyavijayan3:13881-fix-compile-filename-typing

Conversation

vidhyavijayan3
Copy link
Contributor

In Python 3.12 and later, passing a bytearray as thefilename argument to
compile() is no longer allowed. This commit adds a mypy plugin that checks
for this specific misuse and emits an appropriate error message.

The plugin is applied conditionally via mypy.ini and is compatible with the
existing stubs forcompile() in builtins.pyi.

This prevents false positives and ensures correct typing behavior in
accordance with the updated CPython semantics.

Closes#13881

@srittau
Copy link
Collaborator

srittau commentedMay 28, 2025
edited
Loading

Please note that typeshed only provides type annotations, we don't need or want any custom mypy plugins – that would be detrimental to typeshed's purpose. To solve#13881, we just need to change the type annotations forcompile'sfilename argument.Probably toStrPath | bytes, but I haven't looked too deeply into it. ProbablyStrOrBytesPath.

@vidhyavijayan3
Copy link
ContributorAuthor

Thank you for the clarification! I'll remove the custom mypy plugin and instead update the type annotation for the filename parameter in the compile() stub to use StrOrBytesPath, as suggested. Appreciate your feedback and guidance on aligning with typeshed's goals.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3.12+:compile() and some wrappers of it don't accept non-bytes buffers for filename argument at runtime
2 participants
@vidhyavijayan3@srittau

[8]ページ先頭

©2009-2025 Movatter.jp