[New-bugs-announce] [issue37214] Add new EncodingWarning warning category: emitted when the locale encoding is used implicitly

STINNER Victor report at bugs.python.org
Mon Jun 10 06:39:37 EDT 2019


New submission from STINNER Victor <vstinner at redhat.com>:

Spin-off of INADA-san's PEP 597: I propose to emit a new EncodingWarning warning when the locale encoding is used implicitly.

I propose to add a new warning to be able to control how they are handled: either make them hard error (python3.9 -W error::EncodingWarning) or ignore them (python3.9 -W ignore::EncodingWarning).

Displaying these warnings by default or not is an open question discussed in PEP 597 discussion:
https://discuss.python.org/t/pep-597-use-utf-8-for-default-text-file-encoding/1819

I propose to only emit a warning which can be turned off easily to not bother people who don't care of encodings. There are many legit cases where a Python application works well in a control environment whereas it would break on any other environment, but the application is only used in one specific environment. For example, an application may only be run in a container which has a well defined locale and locale encoding, but will never be run on Windows, macOS, FreeBSD or HP-UX.

Writing portable code is *great*. But I'm not sure that *all* code must be portable. For example, it's also fine to use Python to write applications specific to Linux, again, for code only run in a controlled environment. Many companies have private projects which will never run outside their "walls" (outside their datacenters ;-)).

----------
components: Library (Lib)
messages: 345121
nosy: vstinner
priority: normal
severity: normal
status: open
title: Add new EncodingWarning warning category: emitted when the locale encoding is used implicitly
type: enhancement
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37214>
_______________________________________


More information about the New-bugs-announce mailing list