diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py index b9691bbb628..44805bc0b5a 100644 --- a/src/sage/misc/sageinspect.py +++ b/src/sage/misc/sageinspect.py @@ -2062,10 +2062,10 @@ def sage_getdoc(obj, obj_name='', embedded=False): r = sage_getdoc_original(obj) s = sage.misc.sagedoc.format(r, embedded=embedded) f = sage_getfile(obj) - if f: + if f and os.path.exists(f): from sage.doctest.control import skipfile skip = skipfile(f) - if skip: + if isinstance(skip, str): warn = """WARNING: the enclosing module is marked '{}', so doctests may not pass.""".format(skip) s = warn + "\n\n" + s