]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-125225: Fix column misalignment in help('topics') output (gh-125226)
authorÉtienne Pelletier <EtiennePelletier@users.noreply.github.com>
Mon, 19 May 2025 14:10:17 +0000 (10:10 -0400)
committerGitHub <noreply@github.com>
Mon, 19 May 2025 14:10:17 +0000 (16:10 +0200)
The 'help("topics")' output was misaligned due to "ASSIGNMENTEXPRESSIONS"
exceeding the implicit maximum default column width of 19 characters.

Reduced the number of columns from 4 to 3 in the listtopics()
function to allow more space for longer topic names.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Lib/pydoc.py

index def76d076a29892dcd43833a03ce58dcebde16d2..7528178fdcae97f3b5b9f38562ef47f765be2eff 100644 (file)
@@ -2110,7 +2110,7 @@ has the same effect as typing a particular string at the help> prompt.
         self.output.write(_introdoc())
 
     def list(self, items, columns=4, width=80):
-        items = list(sorted(items))
+        items = sorted(items)
         colw = width // columns
         rows = (len(items) + columns - 1) // columns
         for row in range(rows):
@@ -2142,7 +2142,7 @@ to. Enter any symbol to get more help.
 Here is a list of available topics.  Enter any topic name to get more help.
 
 ''')
-        self.list(self.topics.keys())
+        self.list(self.topics.keys(), columns=3)
 
     def showtopic(self, topic, more_xrefs=''):
         try: