Skip to content

Commit be826a5

Browse files
committed
remove un-necessary constant
1 parent b1a1db5 commit be826a5

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Lib/dis.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import types
55
import collections
66
import io
7+
from fileinput import lineno
78

89
from opcode import *
910
from opcode import (
@@ -436,6 +437,8 @@ def __init__(self, file=None, lineno_width=0, offset_width=0, positions_width=0,
436437
*positions_width* sets the width of the instruction positions field (0 omits it)
437438
*label_width* sets the width of the label field
438439
*show_caches* is a boolean indicating whether to display cache lines
440+
441+
If *positions_width* is specified, *lineno_width* is ignored.
439442
"""
440443
self.file = file
441444
self.lineno_width = lineno_width
@@ -465,26 +468,28 @@ def print_instruction(self, instr, mark_as_current=False):
465468
def print_instruction_line(self, instr, mark_as_current):
466469
"""Format instruction details for inclusion in disassembly output."""
467470
lineno_width = self.lineno_width
468-
positions_wdith = self.positions_width
471+
positions_width = self.positions_width
469472
offset_width = self.offset_width
470473
label_width = self.label_width
471474

472-
new_source_line = (lineno_width > 0 and
475+
new_source_line = ((lineno_width > 0 or positions_width > 0) and
473476
instr.starts_line and
474477
instr.offset > 0)
475478
if new_source_line:
476479
print(file=self.file)
477480

478481
fields = []
479482
# Column: Source code line number
480-
if lineno_width or positions_wdith:
481-
if positions_wdith:
483+
if lineno_width or positions_width:
484+
if positions_width:
485+
# reporting positions instead of just line numbers
486+
assert lineno_width > 0
482487
if instr_positions := instr.positions:
483488
ps = tuple('?' if p is None else p for p in instr_positions)
484489
positions_str = "%s:%s-%s:%s" % ps
485-
fields.append(f'{positions_str:{positions_wdith}}')
490+
fields.append(f'{positions_str:{positions_width}}')
486491
else:
487-
fields.append(' ' * positions_wdith)
492+
fields.append(' ' * positions_width)
488493
else:
489494
if instr.starts_line:
490495
lineno_fmt = "%%%dd" if instr.line_number is not None else "%%%ds"
@@ -831,7 +836,6 @@ def _make_labels_map(original_code, exception_entries=()):
831836
return labels_map
832837

833838
_NO_LINENO = ' --'
834-
_NO_POSITION = ' ?:?-?:?'
835839

836840
def _get_lineno_width(linestarts):
837841
if linestarts is None:

0 commit comments

Comments
 (0)