diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2023-11-23 14:34:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-23 14:34:27 (GMT) |
commit | 89ddea4886942b0c27a778a0ad3f0d5ac5f518f0 (patch) | |
tree | fc03119258bc422fe888f671593daccf64dd5162 | |
parent | 9e56eedd018e1a4681789e634016cbb7699dcb8a (diff) | |
download | cpython-89ddea4886942b0c27a778a0ad3f0d5ac5f518f0.zip cpython-89ddea4886942b0c27a778a0ad3f0d5ac5f518f0.tar.gz cpython-89ddea4886942b0c27a778a0ad3f0d5ac5f518f0.tar.bz2 |
gh-112137: change dis output to show no-lineno as -- instead of None (#112335)
-rw-r--r-- | Lib/dis.py | 3 | ||||
-rw-r--r-- | Lib/test/test_dis.py | 30 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2023-11-23-12-37-22.gh-issue-112137.kM46Q6.rst | 1 |
3 files changed, 18 insertions, 16 deletions
@@ -478,7 +478,8 @@ class Instruction(_Instruction): if self.starts_line: lineno_fmt = "%%%dd" if self.line_number is not None else "%%%ds" lineno_fmt = lineno_fmt % lineno_width - fields.append(lineno_fmt % self.line_number) + lineno = self.line_number if self.line_number is not None else '--' + fields.append(lineno_fmt % lineno) else: fields.append(' ' * lineno_width) # Column: Label diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index 0e7c59c..805cd4e 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -412,7 +412,7 @@ dis_traceback = """\ %4d L2: LOAD_FAST_CHECK 1 (tb) RETURN_VALUE -None L3: PUSH_EXC_INFO + -- L3: PUSH_EXC_INFO %4d LOAD_GLOBAL 0 (Exception) CHECK_EXC_MATCH @@ -430,14 +430,14 @@ None L3: PUSH_EXC_INFO %4d LOAD_FAST 1 (tb) RETURN_VALUE -None L6: LOAD_CONST 0 (None) + -- L6: LOAD_CONST 0 (None) STORE_FAST 0 (e) DELETE_FAST 0 (e) RERAISE 1 %4d L7: RERAISE 0 -None L8: COPY 3 + -- L8: COPY 3 POP_EXCEPT RERAISE 1 ExceptionTable: @@ -518,7 +518,7 @@ dis_with = """\ STORE_FAST 2 (y) RETURN_CONST 0 (None) -None L6: COPY 3 + -- L6: COPY 3 POP_EXCEPT RERAISE 1 ExceptionTable: @@ -576,11 +576,11 @@ dis_asyncwith = """\ %4d L12: CLEANUP_THROW -None L13: JUMP_BACKWARD 26 (to L5) + -- L13: JUMP_BACKWARD 26 (to L5) %4d L14: CLEANUP_THROW -None L15: JUMP_BACKWARD 11 (to L11) + -- L15: JUMP_BACKWARD 11 (to L11) %4d L16: PUSH_EXC_INFO WITH_EXCEPT_START @@ -604,7 +604,7 @@ None L15: JUMP_BACKWARD 11 (to L11) STORE_FAST 2 (y) RETURN_CONST 0 (None) -None L24: COPY 3 + -- L24: COPY 3 POP_EXCEPT RERAISE 1 L25: CALL_INTRINSIC_1 3 (INTRINSIC_STOPITERATION_ERROR) @@ -659,7 +659,7 @@ dis_tryfinally = """\ POP_TOP RETURN_VALUE -None L3: PUSH_EXC_INFO + -- L3: PUSH_EXC_INFO %4d LOAD_FAST 1 (b) PUSH_NULL @@ -667,7 +667,7 @@ None L3: PUSH_EXC_INFO POP_TOP RERAISE 0 -None L4: COPY 3 + -- L4: COPY 3 POP_EXCEPT RERAISE 1 ExceptionTable: @@ -693,7 +693,7 @@ dis_tryfinallyconst = """\ POP_TOP RETURN_CONST 1 (1) -None L1: PUSH_EXC_INFO + -- L1: PUSH_EXC_INFO %4d LOAD_FAST 0 (b) PUSH_NULL @@ -701,7 +701,7 @@ None L1: PUSH_EXC_INFO POP_TOP RERAISE 0 -None L2: COPY 3 + -- L2: COPY 3 POP_EXCEPT RERAISE 1 ExceptionTable: @@ -730,7 +730,7 @@ def _h(y): return foo dis_nested_0 = """\ -None MAKE_CELL 0 (y) + -- MAKE_CELL 0 (y) %4d RESUME 0 @@ -752,7 +752,7 @@ None MAKE_CELL 0 (y) dis_nested_1 = """%s Disassembly of <code object foo at 0x..., file "%s", line %d>: -None COPY_FREE_VARS 1 + -- COPY_FREE_VARS 1 MAKE_CELL 0 (x) %4d RESUME 0 @@ -779,7 +779,7 @@ None COPY_FREE_VARS 1 dis_nested_2 = """%s Disassembly of <code object <genexpr> at 0x..., file "%s", line %d>: -None COPY_FREE_VARS 1 + -- COPY_FREE_VARS 1 %4d RETURN_GENERATOR POP_TOP @@ -797,7 +797,7 @@ None COPY_FREE_VARS 1 L3: END_FOR RETURN_CONST 0 (None) -None L4: CALL_INTRINSIC_1 3 (INTRINSIC_STOPITERATION_ERROR) + -- L4: CALL_INTRINSIC_1 3 (INTRINSIC_STOPITERATION_ERROR) RERAISE 1 ExceptionTable: L1 to L4 -> L4 [0] lasti diff --git a/Misc/NEWS.d/next/Library/2023-11-23-12-37-22.gh-issue-112137.kM46Q6.rst b/Misc/NEWS.d/next/Library/2023-11-23-12-37-22.gh-issue-112137.kM46Q6.rst new file mode 100644 index 0000000..1b2e41a --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-11-23-12-37-22.gh-issue-112137.kM46Q6.rst @@ -0,0 +1 @@ +Change :mod:`dis` output to display no-lineno as "--" instead of "None". |