New submission from Jānis Šlapiņš: Hi! Log files are only saved using the system default encoding. On Windows, this means that the current ANSI code page is used. This may lead to a disaster (exceptions may be thrown due to unmappable characters) if you want to log particular text strings in a foreign language, e.g. those read from a source file in the UTF-8 or UTF-16 encoding, and such strings contain characters not available in your ANSI code page. I guess this issue does not affect Linux or Mac OSX as they already use the UTF-8 encoding for their system locales.
Actually, the logging module already has the built-in functionality for setting a particular encoding for output files. However, it was not added as a parameter of the baseConfig function (in __init__.py). I added a patch file with suggested amendments. I already tested writing logs with those changes applied and files are now saved in the specified encoding which differs from the Windows current ANSI page. For example: logging.basicConfig(filename=log_path, filemode='w', encoding='utf-8', format='%(message)s', level=logging.INFO) ---------- components: Library (Lib) files: __init__.py.patch keywords: patch messages: 262150 nosy: janis.slapins priority: normal severity: normal status: open title: logging.baseConfig is missing the encoding parameter type: enhancement versions: Python 3.5 Added file: http://bugs.python.org/file42238/__init__.py.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26606> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com