Skip to content

Commit 8c3dbd7

Browse files
committed
Fix docstrings on optimization level 2 in PyPy.
In CPython, `inspect.getdoc` returns some default string for `__init__`, but on PyPy, it returns None, when using `-OO`. https://foss.heptapod.net/pypy/pypy/-/issues/3534
1 parent 7100b39 commit 8c3dbd7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/matplotlib/patches.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,8 @@ def _make_verts(self):
14511451

14521452

14531453
docstring.interpd.update(
1454-
FancyArrow="\n".join(inspect.getdoc(FancyArrow.__init__).splitlines()[2:]))
1454+
FancyArrow="\n".join(
1455+
(inspect.getdoc(FancyArrow.__init__) or "").splitlines()[2:]))
14551456

14561457

14571458
class CirclePolygon(RegularPolygon):

lib/matplotlib/scale.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,10 +620,11 @@ def _get_scale_docs():
620620
"""
621621
docs = []
622622
for name, scale_class in _scale_mapping.items():
623+
docstring = inspect.getdoc(scale_class.__init__) or ""
623624
docs.extend([
624625
f" {name!r}",
625626
"",
626-
textwrap.indent(inspect.getdoc(scale_class.__init__), " " * 8),
627+
textwrap.indent(docstring, " " * 8),
627628
""
628629
])
629630
return "\n".join(docs)

0 commit comments

Comments
 (0)