Skip to content

Commit 09ffa69

Browse files
authored
GH-105678: Split MAKE_FUNCTION into MAKE_FUNCTION and SET_FUNCTION_ATTRIBUTE (GH-105680)
1 parent 217589d commit 09ffa69

File tree

12 files changed

+480
-430
lines changed

12 files changed

+480
-430
lines changed

Include/internal/pycore_opcode.h

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/opcode.h

Lines changed: 43 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/dis.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
(repr, 'repr'),
3333
(ascii, 'ascii'),
3434
)
35-
MAKE_FUNCTION = opmap['MAKE_FUNCTION']
36-
MAKE_FUNCTION_FLAGS = ('defaults', 'kwdefaults', 'annotations', 'closure')
35+
SET_FUNCTION_ATTRIBUTE = opmap['SET_FUNCTION_ATTRIBUTE']
36+
FUNCTION_ATTR_FLAGS = ('defaults', 'kwdefaults', 'annotations', 'closure')
3737

3838
LOAD_CONST = opmap['LOAD_CONST']
3939
RETURN_CONST = opmap['RETURN_CONST']
@@ -586,8 +586,8 @@ def _get_instructions_bytes(code, varname_from_oparg=None,
586586
if argrepr:
587587
argrepr += ', '
588588
argrepr += 'with format'
589-
elif deop == MAKE_FUNCTION:
590-
argrepr = ', '.join(s for i, s in enumerate(MAKE_FUNCTION_FLAGS)
589+
elif deop == SET_FUNCTION_ATTRIBUTE:
590+
argrepr = ', '.join(s for i, s in enumerate(FUNCTION_ATTR_FLAGS)
591591
if arg & (1<<i))
592592
elif deop == BINARY_OP:
593593
_, argrepr = _nb_ops[arg]

Lib/importlib/_bootstrap_external.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,8 @@ def _write_atomic(path, data, mode=0o666):
448448
# Python 3.13a1 3550 (Plugin optimizer support)
449449
# Python 3.13a1 3551 (Compact superinstructions)
450450

451+
# Python 3.13a1 3554 (Add SET_FUNCTION_ATTRIBUTE)
452+
451453
# Python 3.14 will start with 3600
452454

453455
# Please don't copy-paste the same pre-release tag for new entries above!!!
@@ -463,7 +465,7 @@ def _write_atomic(path, data, mode=0o666):
463465
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
464466
# in PC/launcher.c must also be updated.
465467

466-
MAGIC_NUMBER = (3551).to_bytes(2, 'little') + b'\r\n'
468+
MAGIC_NUMBER = (3554).to_bytes(2, 'little') + b'\r\n'
467469

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

Lib/opcode.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def pseudo_op(name, op, real_ops):
9696
# This helps us catch cases where we attempt to execute a cache.
9797
def_op('RESERVED', 17)
9898

99+
def_op('MAKE_FUNCTION', 24)
99100
def_op('BINARY_SUBSCR', 25)
100101
def_op('BINARY_SLICE', 26)
101102
def_op('STORE_SLICE', 27)
@@ -183,7 +184,6 @@ def pseudo_op(name, op, real_ops):
183184
jrel_op('POP_JUMP_IF_NONE', 129)
184185
def_op('RAISE_VARARGS', 130) # Number of raise arguments (1, 2, or 3)
185186
def_op('GET_AWAITABLE', 131)
186-
def_op('MAKE_FUNCTION', 132) # Flags
187187
def_op('BUILD_SLICE', 133) # Number of items
188188
jrel_op('JUMP_BACKWARD_NO_INTERRUPT', 134) # Number of words to skip (backwards)
189189
def_op('MAKE_CELL', 135)
@@ -234,6 +234,7 @@ def pseudo_op(name, op, real_ops):
234234
name_op('LOAD_FROM_DICT_OR_GLOBALS', 175)
235235
def_op('LOAD_FROM_DICT_OR_DEREF', 176)
236236
hasfree.append(176)
237+
def_op('SET_FUNCTION_ATTRIBUTE', 177) # Attribute
237238

238239
# Optimizer hook
239240
def_op('ENTER_EXECUTOR', 230)

0 commit comments

Comments
 (0)