Title: Not obvious that locale.LC_MESSAGES may not exist sometimes (e.g. on Windows)
Type: enhancement Stage:
Components: Documentation Versions: Python 3.11, Python 3.10, Python 3.9, Python 3.8, Python 3.7, Python 3.6
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, jack__d, richardmines91
Priority: normal Keywords:

Created on 2021-06-10 23:27 by richardmines91, last changed 2021-06-11 07:21 by richardmines91.

File name Uploaded Description Edit
lc_messages_not_exist.png richardmines91, 2021-06-11 07:21 Proof that locale.LC_MESSAGES may not exist in Python
Messages (4)
msg395588 - (view) Author: Richard Mines (richardmines91) * Date: 2021-06-10 23:27
Documentation page:

Code comment saying that locale.LC_MESSAGES doesn't exist sometimes:

Code fragment showing that locale.LC_MESSAGES can be non-existent:

Reading documentation it's not obvious that locale.LC_MESSAGES may not exist (e.g. Windows - Microsoft Store - Python 3.8)
msg395590 - (view) Author: Jack DeVries (jack__d) * Date: 2021-06-10 23:59
Could it be that _locale throws an ImportError whenever LC_MESSAGES doesn't exist? Then, there are fall-backs defined here:
msg395591 - (view) Author: Jack DeVries (jack__d) * Date: 2021-06-11 00:04
Follow-up: nope! My hypothesis was incorrect. This is all that _localemodule.c has to say about LC_MESSAGES:

    ADD_INT(module, LC_MESSAGES);
#endif /* LC_MESSAGES */
msg395607 - (view) Author: Richard Mines (richardmines91) * Date: 2021-06-11 07:21
If you need a proof that it is possible that locale.LC_MESSAGES doesn't exist, I've attached a screenshot. Even more I'm showing that locale.LC_TIME may be equal to 5 which is a placeholder for locale.LC_MESSAGES if there is an ImportError:

OS: Windows 10 20H2
Python: 3.8.10
Exact link to get python:
Date User Action Args
2021-06-11 07:21:26richardmines91setfiles: + lc_messages_not_exist.png

messages: + msg395607
2021-06-11 00:04:49jack__dsetmessages: + msg395591
2021-06-10 23:59:51jack__dsetnosy: + jack__d
messages: + msg395590
2021-06-10 23:27:24richardmines91create