FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add "annotate" SET_FUNCTION_ATTRIBUTE bit to dis. by larryhastings · Pull Request #124566 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion Lib/dis.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
CONVERT_VALUE = opmap['CONVERT_VALUE']

SET_FUNCTION_ATTRIBUTE = opmap['SET_FUNCTION_ATTRIBUTE']
FUNCTION_ATTR_FLAGS = ('defaults', 'kwdefaults', 'annotations', 'closure')
FUNCTION_ATTR_FLAGS = ('defaults', 'kwdefaults', 'annotations', 'closure', 'annotate')

ENTER_EXECUTOR = opmap['ENTER_EXECUTOR']
LOAD_CONST = opmap['LOAD_CONST']
Expand Down
18 changes: 18 additions & 0 deletions Lib/test/test_dis.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,23 @@ def wrap_func_w_kwargs():
RETURN_CONST 3 (None)
"""

fn_with_annotate_str = """
def foo(a: int, b: str) -> str:
return a * b
"""

dis_fn_with_annotate_str = """\
0 RESUME 0

2 LOAD_CONST 0 (<code object __annotate__ at 0x..., file "<dis>", line 2>)
MAKE_FUNCTION
LOAD_CONST 1 (<code object foo at 0x..., file "<dis>", line 2>)
MAKE_FUNCTION
SET_FUNCTION_ATTRIBUTE 16 (annotate)
STORE_NAME 0 (foo)
RETURN_CONST 2 (None)
"""

compound_stmt_str = """\
x = 0
while 1:
Expand Down Expand Up @@ -1098,6 +1115,7 @@ def test_disassemble_str(self):
self.do_disassembly_test(expr_str, dis_expr_str)
self.do_disassembly_test(simple_stmt_str, dis_simple_stmt_str)
self.do_disassembly_test(annot_stmt_str, dis_annot_stmt_str)
self.do_disassembly_test(fn_with_annotate_str, dis_fn_with_annotate_str)
self.do_disassembly_test(compound_stmt_str, dis_compound_stmt_str)

def test_disassemble_bytes(self):
Expand Down

Back | FazBrowse Home | New Git URL