Skip to content

Commit

Permalink
src/sage/misc/sageinspect.py: raise exceptions in _sage_getdoc_unform…
Browse files Browse the repository at this point in the history
…atted

Our _sage_getdoc_unformatted() catches all exceptions and turns them
into the empty string. The side effects of this are pretty bad: this
function is used to generate the help? strings in the sage REPL, and
if something goes wrong, the user will get a confusing blank docstring
rather than the error.

The change was introduced in issue 19671 as a workaround for a runtime
error raised inside flask. But we are no longer using flask, and
hopefully no other parts of the Sage library raise an exception during
the documentation build. We are about to find out!
  • Loading branch information
orlitzky committed Nov 8, 2024
1 parent 1f7a4fb commit 4e79070
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/sage/misc/sageinspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -1865,28 +1865,10 @@ def _sage_getdoc_unformatted(obj):
sage: _sage_getdoc_unformatted(isinstance.__class__)
''
Construct an object raising an exception when accessing the
``__doc__`` attribute. This should not give an error in
``_sage_getdoc_unformatted``, see :issue:`19671`::
sage: class NoSageDoc():
....: @property
....: def __doc__(self):
....: raise Exception("no doc here")
sage: obj = NoSageDoc()
sage: obj.__doc__
Traceback (most recent call last):
...
Exception: no doc here
sage: _sage_getdoc_unformatted(obj)
''
"""
if obj is None:
return ''
try:
r = obj.__doc__
except Exception:
return ''
r = obj.__doc__

# Check if the __doc__ attribute was actually a string, and
# not a 'getset_descriptor' or similar.
Expand Down

0 comments on commit 4e79070

Please sign in to comment.