https://github.com/python/cpython/commit/d2e27aca4bd9da956b40914b1bb840896f2566ec
commit: d2e27aca4bd9da956b40914b1bb840896f2566ec
branch: main
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-06-11T20:50:00+03:00
summary:
gh-150285: Fix overflow in too long lines for class data in pydoc (GH-151366)
Use all available space (80 columns) for formatting reprs
of module and class data, but ensure that they do not overflow.
files:
A Misc/NEWS.d/next/Library/2026-06-11-19-46-16.gh-issue-150285.wuhAsL.rst
M Lib/pydoc.py
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index ca4eb100198168..fe42592530c2cf 100644
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1355,7 +1355,7 @@ def docmodule(self, object, name=None, mod=None,
*ignored):
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 @@ def spilldata(msg, attrs, predicate):
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 @@ def docother(self, object, name=None, mod=None,
parent=None, *ignored,
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
index 00000000000000..3f19150488f313
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-06-11-19-46-16.gh-issue-150285.wuhAsL.rst
@@ -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.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]