@@ -426,31 +426,23 @@ def __str__(self):
426426
427427class Formatter :
428428
429- def __init__ (self , file = None , lineno_width = None , offset_width = 0 , label_width = 0 ,
430- line_offset = 0 , show_caches = False , * , locations_width = 0 ,
431- show_positions = False ):
429+ def __init__ (self , file = None , lineno_width = 0 , offset_width = 0 , label_width = 0 ,
430+ line_offset = 0 , show_caches = False , * , show_positions = False ):
432431 """Create a Formatter
433432
434433 *file* where to write the output
435- *lineno_width* sets the width of the line number field (deprecated )
434+ *lineno_width* sets the width of the line number field (0 omits it )
436435 *offset_width* sets the width of the instruction offset field
437436 *label_width* sets the width of the label field
438437 *show_caches* is a boolean indicating whether to display cache lines
439- *locations_width* sets the width of the instruction locations (0 omits it)
440438 *show_positions* is a boolean indicating whether positions should be
441- reported instead of line numbers
442- """
443- if lineno_width is not None :
444- import warnings
445- warnings .warn ("The 'lineno_width' parameter is deprecated. It is "
446- "now ignored and will be removed in Python 3.16. "
447- "Use 'locations_width' instead." ,
448- DeprecationWarning , stacklevel = 2 )
439+ reported instead of line numbers.
449440
441+ If *show_positions* is true, then *lineno_width* should be computed
442+ accordingly.
443+ """
450444 self .file = file
451- # keep the attribute in case someone is still using it
452- self .lineno_width = 0 if lineno_width is None else lineno_width
453- self .locations_width = locations_width
445+ self .lineno_width = lineno_width
454446 self .offset_width = offset_width
455447 self .label_width = label_width
456448 self .show_caches = show_caches
@@ -476,35 +468,35 @@ def print_instruction(self, instr, mark_as_current=False):
476468
477469 def print_instruction_line (self , instr , mark_as_current ):
478470 """Format instruction details for inclusion in disassembly output."""
479- locations_width = self .locations_width
471+ lineno_width = self .lineno_width
480472 offset_width = self .offset_width
481473 label_width = self .label_width
482474
483- new_source_line = ((locations_width > 0 ) and
475+ new_source_line = ((lineno_width > 0 ) and
484476 instr .starts_line and
485477 instr .offset > 0 )
486478 if new_source_line :
487479 print (file = self .file )
488480
489481 fields = []
490482 # Column: Source code locations information
491- if locations_width :
483+ if lineno_width :
492484 if self .show_positions :
493485 # reporting positions instead of just line numbers
494486 if instr_positions := instr .positions :
495487 ps = tuple ('?' if p is None else p for p in instr_positions )
496488 positions_str = f"{ ps [0 ]} :{ ps [2 ]} -{ ps [1 ]} :{ ps [3 ]} "
497- fields .append (f'{ positions_str :{locations_width }} ' )
489+ fields .append (f'{ positions_str :{lineno_width }} ' )
498490 else :
499- fields .append (' ' * locations_width )
491+ fields .append (' ' * lineno_width )
500492 else :
501493 if instr .starts_line :
502494 lineno_fmt = "%%%dd" if instr .line_number is not None else "%%%ds"
503- lineno_fmt = lineno_fmt % locations_width
495+ lineno_fmt = lineno_fmt % lineno_width
504496 lineno = _NO_LINENO if instr .line_number is None else instr .line_number
505497 fields .append (lineno_fmt % lineno )
506498 else :
507- fields .append (' ' * locations_width )
499+ fields .append (' ' * lineno_width )
508500 # Column: Label
509501 if instr .label is not None :
510502 lbl = f"L{ instr .label } :"
@@ -796,14 +788,14 @@ def disassemble(co, lasti=-1, *, file=None, show_caches=False, adaptive=False,
796788 linestarts = dict (findlinestarts (co ))
797789 exception_entries = _parse_exception_table (co )
798790 if show_positions :
799- locations_width = _get_positions_width (co )
791+ lineno_width = _get_positions_width (co )
800792 else :
801- locations_width = _get_lineno_width (linestarts )
793+ lineno_width = _get_lineno_width (linestarts )
802794 labels_map = _make_labels_map (co .co_code , exception_entries = exception_entries )
803795 label_width = 4 + len (str (len (labels_map )))
804796 formatter = Formatter (file = file ,
797+ lineno_width = lineno_width ,
805798 offset_width = len (str (max (len (co .co_code ) - 2 , 9999 ))) if show_offsets else 0 ,
806- locations_width = locations_width ,
807799 label_width = label_width ,
808800 show_caches = show_caches ,
809801 show_positions = show_positions )
@@ -1079,14 +1071,14 @@ def dis(self):
10791071 code = _get_code_array (co , self .adaptive )
10801072 offset_width = len (str (max (len (code ) - 2 , 9999 ))) if self .show_offsets else 0
10811073 if self .show_positions :
1082- locations_width = _get_positions_width (co )
1074+ lineno_width = _get_positions_width (co )
10831075 else :
1084- locations_width = _get_lineno_width (self ._linestarts )
1076+ lineno_width = _get_lineno_width (self ._linestarts )
10851077 labels_map = _make_labels_map (co .co_code , self .exception_entries )
10861078 label_width = 4 + len (str (len (labels_map )))
10871079 formatter = Formatter (file = output ,
1080+ lineno_width = lineno_width ,
10881081 offset_width = offset_width ,
1089- locations_width = locations_width ,
10901082 label_width = label_width ,
10911083 line_offset = self ._line_offset ,
10921084 show_caches = self .show_caches ,
0 commit comments