classification
Title: string.letters is flipped after setlocale is called
Type: Stage: resolved
Components: Versions: Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: help() modifies the string module
View: 39079
Assigned To: Nosy List: Manishearth, eric.smith
Priority: normal Keywords: patch

Created on 2019-12-18 01:45 by Manishearth, last changed 2019-12-18 02:12 by zach.ware. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 17650 closed Manishearth, 2019-12-18 01:51
Messages (2)
msg358604 - (view) Author: Manish Goregaokar (Manishearth) * Date: 2019-12-18 01:45
Steps to reproduce:

>>> import string
>>> string.letters
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
>>> help(string)
......
>>> string.letters
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'


The help(string) can also be replaced with locale.setlocale(locale.LC_CTYPE, "en_US.UTF-8")

What's happening here is that any call to setlocale() (which help() calls internally) recomputes string.letters. The recomputation flips the order in the current implementation.
msg358606 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2019-12-18 02:01
This is a duplicate of issue 39079.

I recommend that we don't "fix" this. It is only an issue with 2.7, and hasn't been a problem for years.
History
Date User Action Args
2019-12-18 02:12:12zach.waresetstatus: open -> closed
superseder: help() modifies the string module
resolution: duplicate
stage: patch review -> resolved
2019-12-18 02:01:49eric.smithsetnosy: + eric.smith
messages: + msg358606
2019-12-18 01:51:54Manishearthsetkeywords: + patch
stage: patch review
pull_requests: + pull_request17117
2019-12-18 01:45:28Manishearthcreate