This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients martin.panter
Date 2017-01-14.07:25:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1484378754.56.0.202012710496.issue29273@psf.upfronthosting.co.za>
In-reply-to
Content
On a Linux computer I have LANG=en_US.utf8 set. Python 3 initializes the locale with this setting (see revision 43e32b2b4004):

>>> locale.setlocale(locale.LC_CTYPE)  # Get setting initialized by Python
'en_US.utf8'

In Lib/test/test___all__.py, there is a special case to restore the locale after loading the “readline” module (last changed in revision 37ed6eed0595). It does this by calling getlocale() and later setlocale(). However the getlocale() call translates the setting to UTF-8 in uppercase with a dash, and setlocale() keeps it that way:

>>> locale.getlocale(locale.LC_CTYPE)
('en_US', 'UTF-8')
>>> locale.setlocale(locale.LC_CTYPE, _)
'en_US.UTF-8'

This means that the test framework may complain:

Warning -- locale was modified by test___all__

One subtlety is that I only see the warning when the “tkinter” module is unavailable. Otherwise, the test imports Lib/idlelib/iomenu.py, which calls setlocale(locale.LC_CTYPE, "") and restores the original “utf8” spelling.

The easiest fix would be to use setlocale(locale.LC_CTYPE) instead of getlocale() in test___all__. However I think it may be safe to remove this code entirely. The original version of the it was added by Guido in revision ba522c74a931 (year 2002). Three hours later is revision c7d5801bbae8, where Guido changed the “readline” module to restore the locale after Readline library initialization. Since the module is fixed, I don’t think we need the test workaround, and I propose to remove it in Python 3, where it causes the above conflict.
History
Date User Action Args
2017-01-14 07:25:54martin.pantersetrecipients: + martin.panter
2017-01-14 07:25:54martin.pantersetmessageid: <1484378754.56.0.202012710496.issue29273@psf.upfronthosting.co.za>
2017-01-14 07:25:54martin.panterlinkissue29273 messages
2017-01-14 07:25:53martin.pantercreate