mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
Issue #17516: use comment syntax for comments, instead of multiline string
This commit is contained in:
parent
1f8898a591
commit
765531d2d0
11 changed files with 493 additions and 507 deletions
|
@ -299,101 +299,100 @@ def _call_with_frames_removed(f, *args, **kwds):
|
|||
|
||||
# Finder/loader utility code ###############################################
|
||||
|
||||
"""Magic word to reject .pyc files generated by other Python versions.
|
||||
It should change for each incompatible change to the bytecode.
|
||||
# Magic word to reject .pyc files generated by other Python versions.
|
||||
# It should change for each incompatible change to the bytecode.
|
||||
#
|
||||
# The value of CR and LF is incorporated so if you ever read or write
|
||||
# a .pyc file in text mode the magic number will be wrong; also, the
|
||||
# Apple MPW compiler swaps their values, botching string constants.
|
||||
#
|
||||
# The magic numbers must be spaced apart at least 2 values, as the
|
||||
# -U interpeter flag will cause MAGIC+1 being used. They have been
|
||||
# odd numbers for some time now.
|
||||
#
|
||||
# There were a variety of old schemes for setting the magic number.
|
||||
# The current working scheme is to increment the previous value by
|
||||
# 10.
|
||||
#
|
||||
# Starting with the adoption of PEP 3147 in Python 3.2, every bump in magic
|
||||
# number also includes a new "magic tag", i.e. a human readable string used
|
||||
# to represent the magic number in __pycache__ directories. When you change
|
||||
# the magic number, you must also set a new unique magic tag. Generally this
|
||||
# can be named after the Python major version of the magic number bump, but
|
||||
# it can really be anything, as long as it's different than anything else
|
||||
# that's come before. The tags are included in the following table, starting
|
||||
# with Python 3.2a0.
|
||||
#
|
||||
# Known values:
|
||||
# Python 1.5: 20121
|
||||
# Python 1.5.1: 20121
|
||||
# Python 1.5.2: 20121
|
||||
# Python 1.6: 50428
|
||||
# Python 2.0: 50823
|
||||
# Python 2.0.1: 50823
|
||||
# Python 2.1: 60202
|
||||
# Python 2.1.1: 60202
|
||||
# Python 2.1.2: 60202
|
||||
# Python 2.2: 60717
|
||||
# Python 2.3a0: 62011
|
||||
# Python 2.3a0: 62021
|
||||
# Python 2.3a0: 62011 (!)
|
||||
# Python 2.4a0: 62041
|
||||
# Python 2.4a3: 62051
|
||||
# Python 2.4b1: 62061
|
||||
# Python 2.5a0: 62071
|
||||
# Python 2.5a0: 62081 (ast-branch)
|
||||
# Python 2.5a0: 62091 (with)
|
||||
# Python 2.5a0: 62092 (changed WITH_CLEANUP opcode)
|
||||
# Python 2.5b3: 62101 (fix wrong code: for x, in ...)
|
||||
# Python 2.5b3: 62111 (fix wrong code: x += yield)
|
||||
# Python 2.5c1: 62121 (fix wrong lnotab with for loops and
|
||||
# storing constants that should have been removed)
|
||||
# Python 2.5c2: 62131 (fix wrong code: for x, in ... in listcomp/genexp)
|
||||
# Python 2.6a0: 62151 (peephole optimizations and STORE_MAP opcode)
|
||||
# Python 2.6a1: 62161 (WITH_CLEANUP optimization)
|
||||
# Python 2.7a0: 62171 (optimize list comprehensions/change LIST_APPEND)
|
||||
# Python 2.7a0: 62181 (optimize conditional branches:
|
||||
# introduce POP_JUMP_IF_FALSE and POP_JUMP_IF_TRUE)
|
||||
# Python 2.7a0 62191 (introduce SETUP_WITH)
|
||||
# Python 2.7a0 62201 (introduce BUILD_SET)
|
||||
# Python 2.7a0 62211 (introduce MAP_ADD and SET_ADD)
|
||||
# Python 3000: 3000
|
||||
# 3010 (removed UNARY_CONVERT)
|
||||
# 3020 (added BUILD_SET)
|
||||
# 3030 (added keyword-only parameters)
|
||||
# 3040 (added signature annotations)
|
||||
# 3050 (print becomes a function)
|
||||
# 3060 (PEP 3115 metaclass syntax)
|
||||
# 3061 (string literals become unicode)
|
||||
# 3071 (PEP 3109 raise changes)
|
||||
# 3081 (PEP 3137 make __file__ and __name__ unicode)
|
||||
# 3091 (kill str8 interning)
|
||||
# 3101 (merge from 2.6a0, see 62151)
|
||||
# 3103 (__file__ points to source file)
|
||||
# Python 3.0a4: 3111 (WITH_CLEANUP optimization).
|
||||
# Python 3.0a5: 3131 (lexical exception stacking, including POP_EXCEPT)
|
||||
# Python 3.1a0: 3141 (optimize list, set and dict comprehensions:
|
||||
# change LIST_APPEND and SET_ADD, add MAP_ADD)
|
||||
# Python 3.1a0: 3151 (optimize conditional branches:
|
||||
# introduce POP_JUMP_IF_FALSE and POP_JUMP_IF_TRUE)
|
||||
# Python 3.2a0: 3160 (add SETUP_WITH)
|
||||
# tag: cpython-32
|
||||
# Python 3.2a1: 3170 (add DUP_TOP_TWO, remove DUP_TOPX and ROT_FOUR)
|
||||
# tag: cpython-32
|
||||
# Python 3.2a2 3180 (add DELETE_DEREF)
|
||||
# Python 3.3a0 3190 __class__ super closure changed
|
||||
# Python 3.3a0 3200 (__qualname__ added)
|
||||
# 3210 (added size modulo 2**32 to the pyc header)
|
||||
# Python 3.3a1 3220 (changed PEP 380 implementation)
|
||||
# Python 3.3a4 3230 (revert changes to implicit __class__ closure)
|
||||
# Python 3.4a1 3250 (evaluate positional default arguments before
|
||||
# keyword-only defaults)
|
||||
#
|
||||
# MAGIC must change whenever the bytecode emitted by the compiler may no
|
||||
# longer be understood by older implementations of the eval loop (usually
|
||||
# due to the addition of new opcodes).
|
||||
|
||||
The value of CR and LF is incorporated so if you ever read or write
|
||||
a .pyc file in text mode the magic number will be wrong; also, the
|
||||
Apple MPW compiler swaps their values, botching string constants.
|
||||
|
||||
The magic numbers must be spaced apart at least 2 values, as the
|
||||
-U interpeter flag will cause MAGIC+1 being used. They have been
|
||||
odd numbers for some time now.
|
||||
|
||||
There were a variety of old schemes for setting the magic number.
|
||||
The current working scheme is to increment the previous value by
|
||||
10.
|
||||
|
||||
Starting with the adoption of PEP 3147 in Python 3.2, every bump in magic
|
||||
number also includes a new "magic tag", i.e. a human readable string used
|
||||
to represent the magic number in __pycache__ directories. When you change
|
||||
the magic number, you must also set a new unique magic tag. Generally this
|
||||
can be named after the Python major version of the magic number bump, but
|
||||
it can really be anything, as long as it's different than anything else
|
||||
that's come before. The tags are included in the following table, starting
|
||||
with Python 3.2a0.
|
||||
|
||||
Known values:
|
||||
Python 1.5: 20121
|
||||
Python 1.5.1: 20121
|
||||
Python 1.5.2: 20121
|
||||
Python 1.6: 50428
|
||||
Python 2.0: 50823
|
||||
Python 2.0.1: 50823
|
||||
Python 2.1: 60202
|
||||
Python 2.1.1: 60202
|
||||
Python 2.1.2: 60202
|
||||
Python 2.2: 60717
|
||||
Python 2.3a0: 62011
|
||||
Python 2.3a0: 62021
|
||||
Python 2.3a0: 62011 (!)
|
||||
Python 2.4a0: 62041
|
||||
Python 2.4a3: 62051
|
||||
Python 2.4b1: 62061
|
||||
Python 2.5a0: 62071
|
||||
Python 2.5a0: 62081 (ast-branch)
|
||||
Python 2.5a0: 62091 (with)
|
||||
Python 2.5a0: 62092 (changed WITH_CLEANUP opcode)
|
||||
Python 2.5b3: 62101 (fix wrong code: for x, in ...)
|
||||
Python 2.5b3: 62111 (fix wrong code: x += yield)
|
||||
Python 2.5c1: 62121 (fix wrong lnotab with for loops and
|
||||
storing constants that should have been removed)
|
||||
Python 2.5c2: 62131 (fix wrong code: for x, in ... in listcomp/genexp)
|
||||
Python 2.6a0: 62151 (peephole optimizations and STORE_MAP opcode)
|
||||
Python 2.6a1: 62161 (WITH_CLEANUP optimization)
|
||||
Python 2.7a0: 62171 (optimize list comprehensions/change LIST_APPEND)
|
||||
Python 2.7a0: 62181 (optimize conditional branches:
|
||||
introduce POP_JUMP_IF_FALSE and POP_JUMP_IF_TRUE)
|
||||
Python 2.7a0 62191 (introduce SETUP_WITH)
|
||||
Python 2.7a0 62201 (introduce BUILD_SET)
|
||||
Python 2.7a0 62211 (introduce MAP_ADD and SET_ADD)
|
||||
Python 3000: 3000
|
||||
3010 (removed UNARY_CONVERT)
|
||||
3020 (added BUILD_SET)
|
||||
3030 (added keyword-only parameters)
|
||||
3040 (added signature annotations)
|
||||
3050 (print becomes a function)
|
||||
3060 (PEP 3115 metaclass syntax)
|
||||
3061 (string literals become unicode)
|
||||
3071 (PEP 3109 raise changes)
|
||||
3081 (PEP 3137 make __file__ and __name__ unicode)
|
||||
3091 (kill str8 interning)
|
||||
3101 (merge from 2.6a0, see 62151)
|
||||
3103 (__file__ points to source file)
|
||||
Python 3.0a4: 3111 (WITH_CLEANUP optimization).
|
||||
Python 3.0a5: 3131 (lexical exception stacking, including POP_EXCEPT)
|
||||
Python 3.1a0: 3141 (optimize list, set and dict comprehensions:
|
||||
change LIST_APPEND and SET_ADD, add MAP_ADD)
|
||||
Python 3.1a0: 3151 (optimize conditional branches:
|
||||
introduce POP_JUMP_IF_FALSE and POP_JUMP_IF_TRUE)
|
||||
Python 3.2a0: 3160 (add SETUP_WITH)
|
||||
tag: cpython-32
|
||||
Python 3.2a1: 3170 (add DUP_TOP_TWO, remove DUP_TOPX and ROT_FOUR)
|
||||
tag: cpython-32
|
||||
Python 3.2a2 3180 (add DELETE_DEREF)
|
||||
Python 3.3a0 3190 __class__ super closure changed
|
||||
Python 3.3a0 3200 (__qualname__ added)
|
||||
3210 (added size modulo 2**32 to the pyc header)
|
||||
Python 3.3a1 3220 (changed PEP 380 implementation)
|
||||
Python 3.3a4 3230 (revert changes to implicit __class__ closure)
|
||||
Python 3.4a1 3250 (evaluate positional default arguments before
|
||||
keyword-only defaults)
|
||||
|
||||
MAGIC must change whenever the bytecode emitted by the compiler may no
|
||||
longer be understood by older implementations of the eval loop (usually
|
||||
due to the addition of new opcodes).
|
||||
|
||||
"""
|
||||
_MAGIC_BYTES = (3250).to_bytes(2, 'little') + b'\r\n'
|
||||
_RAW_MAGIC_NUMBER = int.from_bytes(_MAGIC_BYTES, 'little')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue