]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-150285: Fix overflow in too long lines for class data in pydoc (GH-151366)
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 11 Jun 2026 17:50:00 +0000 (20:50 +0300)
committerGitHub <noreply@github.com>
Thu, 11 Jun 2026 17:50:00 +0000 (20:50 +0300)
Use all available space (80 columns) for formatting reprs
of module and class data, but ensure that they do not overflow.

Lib/pydoc.py
Misc/NEWS.d/next/Library/2026-06-11-19-46-16.gh-issue-150285.wuhAsL.rst [new file with mode: 0644]

index ca4eb1001981681e0982f75648a1a48e4bb95a5c..fe42592530c2cfd5cbc9ffe20c2bd66ca583d929 100644 (file)
@@ -1355,7 +1355,7 @@ location listed above.
         if data:
             contents = []
             for key, value in data:
-                contents.append(self.docother(value, key, name, maxlen=70))
+                contents.append(self.docother(value, key, name, maxlen=76))
             result = result + self.section('DATA', '\n'.join(contents))
 
         if version := self._get_version(object):
@@ -1478,7 +1478,7 @@ location listed above.
                         obj = getattr(object, name)
                     except AttributeError:
                         obj = homecls.__dict__[name]
-                    push(self.docother(obj, name, mod, maxlen=70, doc=doc) +
+                    push(self.docother(obj, name, mod, maxlen=72, doc=doc) +
                          '\n')
             return attrs
 
@@ -1629,7 +1629,7 @@ location listed above.
         if maxlen:
             line = (name and name + ' = ' or '') + repr
             chop = maxlen - len(line)
-            if chop < 0: repr = repr[:chop] + '...'
+            if chop < 0: repr = repr[:chop-3] + '...'
         line = (name and self.bold(name) + ' = ' or '') + repr
         if not doc:
             doc = getdoc(object)
diff --git a/Misc/NEWS.d/next/Library/2026-06-11-19-46-16.gh-issue-150285.wuhAsL.rst b/Misc/NEWS.d/next/Library/2026-06-11-19-46-16.gh-issue-150285.wuhAsL.rst
new file mode 100644 (file)
index 0000000..3f19150
--- /dev/null
@@ -0,0 +1,2 @@
+:mod:`pydoc` now uses all available space (80 columns) for formatting reprs
+of module and class data, but ensure that they do not overflow.