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 stefanhoelzl
Recipients stefanhoelzl
Date 2021-07-18.08:57:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1626598631.59.0.122481145082.issue44666@roundup.psfhosted.org>
In-reply-to
Content
compile_files tries to escape non-printable characters in error messages by using sys.stdout.encoding
https://github.com/python/cpython/blob/main/Lib/compileall.py#L256

when using contextlib.redirect_stdout to redirect stdout to io.StringIO as explained in the documentation
https://docs.python.org/3/library/contextlib.html#contextlib.redirect_stdout

compile_file fails, because io.StringIO has encoding set to None.

see the attached file to reproduce the issue
History
Date User Action Args
2021-07-18 08:57:11stefanhoelzlsetrecipients: + stefanhoelzl
2021-07-18 08:57:11stefanhoelzlsetmessageid: <1626598631.59.0.122481145082.issue44666@roundup.psfhosted.org>
2021-07-18 08:57:11stefanhoelzllinkissue44666 messages
2021-07-18 08:57:11stefanhoelzlcreate