cpython/Doc/c-api
Victor Stinner e662c398d8
bpo-42236: Use UTF-8 encoding if nl_langinfo(CODESET) fails (GH-23086)
If the nl_langinfo(CODESET) function returns an empty string, Python
now uses UTF-8 as the filesystem encoding.

In May 2010 (commit b744ba1d14), I
modified Python to log a warning and use UTF-8 as the filesystem
encoding (instead of None) if nl_langinfo(CODESET) returns an empty
string.

In August 2020 (commit 94908bbc15), I
modified Python startup to fail with a fatal error and a specific
error message if nl_langinfo(CODESET) returns an empty string. The
intent was to prevent guessing the encoding and also investigate user
configuration where this case happens.

In 10 years (2010 to 2020), I saw zero user report about the error
message related to nl_langinfo(CODESET) returning an empty string.

Today, UTF-8 became the defacto standard and it's safe to make the
assumption that the user expects UTF-8. For example,
nl_langinfo(CODESET) can return an empty string on macOS if the
LC_CTYPE locale is not supported, and UTF-8 is the default encoding
on macOS.

While this change is likely to not affect anyone in practice, it
should make UTF-8 lover happy ;-)

Rewrite also the documentation explaining how Python selects the
filesystem encoding and error handler.
2020-11-01 23:07:23 +01:00
..
abstract.rst bpo-41103: Remove old buffer protocol support (#21117) 2020-06-26 08:07:22 +09:00
allocation.rst bpo-37432: Doc: Fix signature of PyObject_Del() (GH-14430) 2019-06-28 18:02:56 +09:00
apiabiversion.rst Doc: Replace the deprecated highlightlang directive by highlight. (#13377) 2019-05-17 15:25:34 +05:30
arg.rst bpo-40204, doc: Fix syntax of C variables (GH-21846) 2020-08-13 22:11:50 +02:00
bool.rst Doc: Replace the deprecated highlightlang directive by highlight. (#13377) 2019-05-17 15:25:34 +05:30
buffer.rst bpo-40204, doc: Fix syntax of C variables (GH-21846) 2020-08-13 22:11:50 +02:00
bytearray.rst bpo-38600: Change the mark up of NULL in the C API documentation. (GH-16950) 2019-10-30 12:03:20 +02:00
bytes.rst bpo-38600: Change the mark up of NULL in the C API documentation. (GH-16950) 2019-10-30 12:03:20 +02:00
call.rst bpo-40204, doc: Fix syntax of C variables (GH-21846) 2020-08-13 22:11:50 +02:00
capsule.rst bpo-40204, doc: Fix syntax of C variables (GH-21846) 2020-08-13 22:11:50 +02:00
cell.rst bpo-38600: Change the mark up of NULL in the C API documentation. (GH-16950) 2019-10-30 12:03:20 +02:00
code.rst Fix the miscellaneous typo (GH-17700) 2019-12-25 07:39:35 -08:00
codec.rst bpo-41842: Add codecs.unregister() function (GH-22360) 2020-09-28 23:41:11 +02:00
complex.rst bpo-20092. Use __index__ in constructors of int, float and complex. (GH-13108) 2019-06-02 00:05:48 +03:00
concrete.rst bpo-41324 Add a minimal decimal capsule API (#21519) 2020-08-10 16:32:21 +02:00
contextvars.rst bpo-40428: Remove references to Py*_ClearFreeList in the docs (GH-19783) 2020-04-29 04:41:56 +02:00
conversion.rst bpo-36020: Require vsnprintf() to build Python (GH-20899) 2020-06-16 00:54:44 +02:00
coro.rst bpo-38600: NULL -> `NULL`. (GH-17001) 2019-10-30 21:37:16 +02:00
datetime.rst bpo-30155: Add macros to get tzinfo from datetime instances (GH-21633) 2020-09-23 14:43:45 -04:00
decimal.rst Fix .. code-block :: directives in decimal.rst (GH-22571) 2020-10-11 19:26:50 +01:00
descriptor.rst Doc: Replace the deprecated highlightlang directive by highlight. (#13377) 2019-05-17 15:25:34 +05:30
dict.rst bpo-41802: Document 'PyDict_DelItem' can raise a 'KeyError' (GH-22291) 2020-10-02 19:18:01 +03:00
exceptions.rst bpo-40204, doc: Fix syntax of C variables (GH-21846) 2020-08-13 22:11:50 +02:00
file.rst bpo-41192: Add documentation of undocumented audit events (GH-21308) 2020-10-20 15:23:15 -04:00
float.rst bpo-40428: Remove references to Py*_ClearFreeList in the docs (GH-19783) 2020-04-29 04:41:56 +02:00
function.rst bpo-38600: NULL -> `NULL`. (GH-17001) 2019-10-30 21:37:16 +02:00
gcsupport.rst bpo-40170: Convert PyObject_IS_GC() macro to a function (GH-19464) 2020-04-14 20:11:20 +02:00
gen.rst Delete PyGen_Send (#22663) 2020-10-12 12:10:42 -07:00
import.rst bpo-38600: NULL -> `NULL`. (GH-17001) 2019-10-30 21:37:16 +02:00
index.rst bpo-36763: Implement the PEP 587 (GH-13592) 2019-05-27 16:39:22 +02:00
init.rst bpo-40204, doc: Fix syntax of C variables (GH-21846) 2020-08-13 22:11:50 +02:00
init_config.rst bpo-42236: Use UTF-8 encoding if nl_langinfo(CODESET) fails (GH-23086) 2020-11-01 23:07:23 +01:00
intro.rst bpo-40204, doc: Fix syntax of C variables (GH-21846) 2020-08-13 22:11:50 +02:00
iter.rst bpo-41756: Export PyGen_Send and wrap it in if-defs (#22677) 2020-10-13 10:26:51 -07:00
iterator.rst Doc: Replace the deprecated highlightlang directive by highlight. (#13377) 2019-05-17 15:25:34 +05:30
list.rst bpo-40428: Remove references to Py*_ClearFreeList in the docs (GH-19783) 2020-04-29 04:41:56 +02:00
long.rst bpo-41211: Doc: Fix PyLong_FromUnicodeObject (GH-21325) 2020-07-05 13:01:48 +09:00
mapping.rst bpo-39153: Clarify C API *SetItem refcounting semantics (GH-18220) 2020-01-29 21:20:53 +10:00
marshal.rst bpo-40204, doc: Fix syntax of C variables (GH-21846) 2020-08-13 22:11:50 +02:00
memory.rst bpo-40204, doc: Fix syntax of C variables (GH-21846) 2020-08-13 22:11:50 +02:00
memoryview.rst bpo-38600: Change the mark up of NULL in the C API documentation. (GH-16950) 2019-10-30 12:03:20 +02:00
method.rst bpo-40428: Remove references to Py*_ClearFreeList in the docs (GH-19783) 2020-04-29 04:41:56 +02:00
module.rst bpo-40204, doc: Fix syntax of C variables (GH-21846) 2020-08-13 22:11:50 +02:00
none.rst Doc: Replace the deprecated highlightlang directive by highlight. (#13377) 2019-05-17 15:25:34 +05:30
number.rst bpo-40792: Make the result of PyNumber_Index() always having exact type int. (GH-20443) 2020-05-28 10:33:45 +03:00
object.rst bpo-40204, doc: Fix syntax of C variables (GH-21846) 2020-08-13 22:11:50 +02:00
objimpl.rst Doc: Replace the deprecated highlightlang directive by highlight. (#13377) 2019-05-17 15:25:34 +05:30
refcounting.rst bpo-38600: Change the mark up of NULL in the C API documentation. (GH-16950) 2019-10-30 12:03:20 +02:00
reflection.rst bpo-40421: Add PyFrame_GetBack() function (GH-19765) 2020-04-29 03:28:46 +02:00
sequence.rst bpo-38600: Change the mark up of NULL in the C API documentation. (GH-16950) 2019-10-30 12:03:20 +02:00
set.rst bpo-40428: Remove references to Py*_ClearFreeList in the docs (GH-19783) 2020-04-29 04:41:56 +02:00
slice.rst bpo-38600: Change the mark up of NULL in the C API documentation. (GH-16950) 2019-10-30 12:03:20 +02:00
stable.rst Doc: Replace the deprecated highlightlang directive by highlight. (#13377) 2019-05-17 15:25:34 +05:30
structures.rst bpo-40204, doc: Fix syntax of C variables (GH-21846) 2020-08-13 22:11:50 +02:00
sys.rst bpo-39882: Py_FatalError() logs the function name (GH-18819) 2020-03-07 00:54:20 +01:00
tuple.rst bpo-40204, doc: Fix syntax of C variables (GH-21846) 2020-08-13 22:11:50 +02:00
type.rst Note the buffer slots can be set with PyType_Spec with the unlimited API. (GH-22031) 2020-09-01 20:36:42 -05:00
typeobj.rst bpo-40204, doc: Fix syntax of C variables (GH-21846) 2020-08-13 22:11:50 +02:00
unicode.rst bpo-41784: make PyUnicode_AsUTF8AndSize part of the limited API (GH-22252) 2020-10-19 23:17:50 +01:00
utilities.rst Doc: Replace the deprecated highlightlang directive by highlight. (#13377) 2019-05-17 15:25:34 +05:30
veryhigh.rst bpo-40204, doc: Fix syntax of C variables (GH-21846) 2020-08-13 22:11:50 +02:00
weakref.rst bpo-38600: Change the mark up of NULL in the C API documentation. (GH-16950) 2019-10-30 12:03:20 +02:00