Skip to content

Move opcode magic number out of Lib/importlib/_bootstrap_external.py #122188

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
brettcannon opened this issue Jul 23, 2024 · 1 comment
Closed
Assignees
Labels
3.14 bugs and security fixes topic-importlib type-feature A feature request or enhancement

Comments

@brettcannon
Copy link
Member

brettcannon commented Jul 23, 2024

Feature or enhancement

Proposal:

The number changes way more frequently than it used to, and currently triggers a review request for CODEOWNERS on Lib/importlib. Maybe it's time to put it in its own file somewhere else?

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

@brettcannon brettcannon added type-feature A feature request or enhancement topic-importlib labels Jul 23, 2024
@serhiy-storchaka
Copy link
Member

I suggest also to move the history list of magic numbers to some other text file. Currently, adding a line changes line numbers and affects a lot of generated C lines in the frozen _bootstrap_external bytecode. This file can also be parsed to generate the versions table for the py launcher.

@mdboom mdboom self-assigned this Jul 24, 2024
mdboom added a commit to mdboom/cpython that referenced this issue Jul 24, 2024
mdboom added a commit that referenced this issue Jul 30, 2024
* gh-122188: Move magic number to its own file

* Add versionadded directive

* Do work in C

* Integrate launcher.c

* Make _pyc_magic_number private

* Remove metadata

* Move sys.implementation -> _imp

* Modernize comment

* Move _RAW_MAGIC_NUMBER to the C side as well

* _pyc_magic_number -> pyc_magic_number

* Remove unused import

* Update docs

* Apply suggestions from code review

Co-authored-by: Eric Snow <[email protected]>

* Fix typo in tests

---------

Co-authored-by: Eric Snow <[email protected]>
@mdboom mdboom closed this as completed Jul 30, 2024
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Jul 31, 2024
_imp.pyc_magic_number_token should be enough.
serhiy-storchaka added a commit that referenced this issue Aug 2, 2024
_imp.pyc_magic_number_token should be enough.
@serhiy-storchaka serhiy-storchaka added the 3.14 bugs and security fixes label Aug 2, 2024
brandtbucher pushed a commit to brandtbucher/cpython that referenced this issue Aug 7, 2024
_imp.pyc_magic_number_token should be enough.
blhsing pushed a commit to blhsing/cpython that referenced this issue Aug 22, 2024
* pythongh-122188: Move magic number to its own file

* Add versionadded directive

* Do work in C

* Integrate launcher.c

* Make _pyc_magic_number private

* Remove metadata

* Move sys.implementation -> _imp

* Modernize comment

* Move _RAW_MAGIC_NUMBER to the C side as well

* _pyc_magic_number -> pyc_magic_number

* Remove unused import

* Update docs

* Apply suggestions from code review

Co-authored-by: Eric Snow <[email protected]>

* Fix typo in tests

---------

Co-authored-by: Eric Snow <[email protected]>
blhsing pushed a commit to blhsing/cpython that referenced this issue Aug 22, 2024
_imp.pyc_magic_number_token should be enough.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.14 bugs and security fixes topic-importlib type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants