This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bskinn
Recipients brett.cannon, bskinn, takluyver, vstinner, xtreak
Date 2019-04-22.15:21:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1555946488.63.0.794230566474.issue36695@roundup.psfhosted.org>
In-reply-to
Content
<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.
History
Date User Action Args
2019-04-22 15:21:28bskinnsetrecipients: + bskinn, brett.cannon, vstinner, takluyver, xtreak
2019-04-22 15:21:28bskinnsetmessageid: <1555946488.63.0.794230566474.issue36695@roundup.psfhosted.org>
2019-04-22 15:21:28bskinnlinkissue36695 messages
2019-04-22 15:21:28bskinncreate