diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2023-11-04 09:54:10 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-04 09:54:10 (GMT) |
commit | 18c954849bcdd5acb6ef91cd90d92f3b5c685134 (patch) | |
tree | 35c267c07653bedf6b2f8e0dd7b95f7aceba8110 /Lib/doctest.py | |
parent | a8e1f474c20ab15140dd0cfcb96b696857907a60 (diff) | |
download | cpython-18c954849bcdd5acb6ef91cd90d92f3b5c685134.zip cpython-18c954849bcdd5acb6ef91cd90d92f3b5c685134.tar.gz cpython-18c954849bcdd5acb6ef91cd90d92f3b5c685134.tar.bz2 |
gh-111159: Fix `SyntaxError` doctests for non-builtin exception classes (#111541)
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r-- | Lib/doctest.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py index f00d935..2f14aa0 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -1399,10 +1399,14 @@ class DocTestRunner: # we don't care about the carets / suggestions / etc # We only care about the error message and notes. # They start with `SyntaxError:` (or any other class name) + exception_line_prefixes = ( + f"{exception[0].__qualname__}:", + f"{exception[0].__module__}.{exception[0].__qualname__}:", + ) exc_msg_index = next( index for index, line in enumerate(formatted_ex) - if line.startswith(f"{exception[0].__name__}:") + if line.startswith(exception_line_prefixes) ) formatted_ex = formatted_ex[exc_msg_index:] |