Message340796
The 'single' option to compile() means it's run like at a REPL, calling displayhook if it's an expression returning a value.
But warnings shouldn't go through the displayhook, as far as I know:
>>> from contextlib import redirect_stdout, redirect_stderr
>>> from io import StringIO
>>> sio = StringIO()
>>> with redirect_stderr(sio):
... exec(compile('import warnings; warnings.warn(""" \' " """)', 'dummyfile', 'single'))
...
>>> print(sio.getvalue())
__main__:1: UserWarning: ' " |
|
Date |
User |
Action |
Args |
2019-04-24 17:44:24 | takluyver | set | recipients:
+ takluyver, brett.cannon, bskinn, xtreak |
2019-04-24 17:44:24 | takluyver | set | messageid: <1556127864.75.0.226503385613.issue36695@roundup.psfhosted.org> |
2019-04-24 17:44:24 | takluyver | link | issue36695 messages |
2019-04-24 17:44:24 | takluyver | create | |
|