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, xtreak
Date 2019-04-24.18:11:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1556129466.12.0.567442136485.issue36695@roundup.psfhosted.org>
In-reply-to
Content
Well, the warning content *itself* may not get passed through the displayhook at raise-time, in the process of being run through stderr and displayed by the REPL.

But, when you capture the warning content with redirect_stderr(sio) and then ">>> sio.getvalue()", the contents of the capture from stderr, as produced by .getvalue(), *will* get passed through the displayhook, and thus be escaped.



In theory, I could have obtained a consistent 'want' by using print() as you've done. However, for my particular example (see OP), I wanted to elide the first part of the warning message, which is messy, irrelevant to my code example, and can change from Python version to Python version. However, as doctest is currently implemented, a 'want' can't start with an ellipsis because it collides with the regex that detects PS2 prompts (https://github.com/python/cpython/blob/4f5a3493b534a95fbb01d593b1ffe320db6b395e/Lib/doctest.py#L583-L586).

See #36714 (https://bugs.python.org/issue36714) for more information and a proposed enhancement/fix.
History
Date User Action Args
2019-04-24 18:11:06bskinnsetrecipients: + bskinn, brett.cannon, takluyver, xtreak
2019-04-24 18:11:06bskinnsetmessageid: <1556129466.12.0.567442136485.issue36695@roundup.psfhosted.org>
2019-04-24 18:11:06bskinnlinkissue36695 messages
2019-04-24 18:11:05bskinncreate