Brian Skinn <bsk...@alum.mit.edu> added the comment:

<nod>, it seems like the problem must somehow stem from the new commit using 
frame.f_code.co_filename (or the C equivalent), instead of using __file__ as 
previously.

Consider this warn2.py, similar to the other but with no single quotes in the 
warning message:

```
import doctest

class Tester:
    r"""Provide docstring for testing.

    >>> import warnings
    >>> from contextlib import redirect_stderr
    >>> from io import StringIO
    >>> sio = StringIO()
    >>> with redirect_stderr(sio):
    ...     warnings.warn("Warning with no quotes")
    >>> sio.getvalue()
    '...'

    """

doctest.run_docstring_examples(
    Tester(),
    {},
    optionflags=doctest.ELLIPSIS,
)
```

This doctest PASSES for me in both 3.7 and 3.8; note that the expected doctest 
output from `sio.getvalue()` is *single-quote delimited*. This implies to me 
that REPL string output is single-quote delimited by default, and that there's 
some sort of "smart string formatter" functionality involved that is working 
correctly in 3.7 but not in 3.8, which REPL-prints the single-quote-containing 
string using enclosing double-quotes, so as to avoid escaping the internal 
single quotes.

Why 11a8966 would break this in this way is ... baffling to me.

---

Unfortunately, I don't think it will work to fix the doctest on my end simply 
by using `print(sio.getvalue())`, as the resulting message is one line long in 
3.7, but two lines long in 3.8. Further, doctest gets confused when you try to 
start a line of output with an ellipsis, as it thinks it's a continuation of 
the prior command.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36695>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to