Skip to content

Commit

Permalink
Bump magic number to account for lazy imports opcode change
Browse files Browse the repository at this point in the history
Summary:
we should have bumped this as part of D52812410
better late than never...

Reviewed By: bowiechen

Differential Revision: D54570036

fbshipit-source-id: 4b5c877d63c951e39d3952f13bd0d2a3b2490364
  • Loading branch information
itamaro authored and facebook-github-bot committed Mar 6, 2024
1 parent 276e2ec commit 1840b0c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Lib/importlib/_bootstrap_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ def _write_atomic(path, data, mode=0o666):
# Python 3.12b1 3529 (Inline list/dict/set comprehensions)
# Python 3.12b1 3530 (Shrink the LOAD_SUPER_ATTR caches)
# Python 3.12b1 3531 (Add PEP 695 changes)
# [META] Python 3.12.2 3532 (Apply lazy imports patch)

# Python 3.13 will start with 3550

Expand All @@ -462,7 +463,9 @@ def _write_atomic(path, data, mode=0o666):
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
# in PC/launcher.c must also be updated.

MAGIC_NUMBER = (3531).to_bytes(2, 'little') + b'\r\n'
# START META PATCH (bump magic number to account for lazy imports opcode change)
MAGIC_NUMBER = (3532).to_bytes(2, 'little') + b'\r\n'
# END META PATCH

_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c

Expand Down
7 changes: 3 additions & 4 deletions Lib/test/test_importlib/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,10 +615,9 @@ class MagicNumberTests(unittest.TestCase):
"""
Test release compatibility issues relating to importlib
"""
@unittest.skipUnless(
sys.version_info.releaselevel in ('candidate', 'final'),
'only applies to candidate or final python release levels'
)
# START META PATCH (skip magic number test)
@unittest.skip('only applies to upstream')
# END META PATCH
def test_magic_number(self):
# Each python minor release should generally have a MAGIC_NUMBER
# that does not change once the release reaches candidate status.
Expand Down

0 comments on commit 1840b0c

Please sign in to comment.