New submission from Stefan Hölzl <stefanh+pythonb...@posteo.de>: 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 ---------- components: Library (Lib) files: compile_file_bug.py messages: 397743 nosy: stefanhoelzl priority: normal severity: normal status: open title: compileall.compile_file fails when sys.stdout is redirected to StringIO type: crash versions: Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8, Python 3.9 Added file: https://bugs.python.org/file50156/compile_file_bug.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44666> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com