New GitHub issue #111159 from sobolevn:<br>

<hr>

<pre>
# Bug report

Minimal reproducer:

```python
"""
Module doctest

>>> raise_with_note()
Traceback (most recent call last):
  ...
ValueError: Text
Note
"""

def raise_with_note():
    err = ValueError('Text')
    err.add_note('Note')
    raise err
```

Now, run it, you will get a very strange error:

```
ยป ./python.exe -m doctest ex.py
**********************************************************************
File "/Users/sobolev/Desktop/cpython/ex.py", line 4, in ex
Failed example:
    raise_with_note()
Expected:
    Traceback (most recent call last):
      ...
    ValueError: Text
    Note
Got:
    Traceback (most recent call last):
      File "/Users/sobolev/Desktop/cpython/Lib/doctest.py", line 1374, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest ex[0]>", line 1, in <module>
        raise_with_note()
      File "/Users/sobolev/Desktop/cpython/ex.py", line 14, in raise_with_note
        raise err
    ValueError: Text
    Note
**********************************************************************
1 items had failures:
   1 of   1 in ex
***Test Failed*** 1 failures.
```

Things that do not help:
- `IGNORE_EXCEPTION_DETAIL`
- `ELLIPSIS`
- Coping the whole traceback

Related to how exceptions with notes are represented in https://github.com/python/cpython/blob/7237fb578dc9db9dc557759a24d8083425107b91/Lib/doctest.py#L1396

I am working on this issue right now :)

Refs https://github.com/python/cpython/issues/111157
</pre>

<hr>

<a href="https://github.com/python/cpython/issues/111159">View on GitHub</a>
<p>Labels: type-bug, stdlib</p>
<p>Assignee: sobolevn</p>