From 4e790703c6036f71c019572dc3f259f2280c29d6 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 8 Nov 2024 08:28:51 -0500 Subject: [PATCH] src/sage/misc/sageinspect.py: raise exceptions in _sage_getdoc_unformatted 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! --- src/sage/misc/sageinspect.py | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py index 1f2a39d7c78..faea717ba52 100644 --- a/src/sage/misc/sageinspect.py +++ b/src/sage/misc/sageinspect.py @@ -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.