Python 2.6 string issue
On latest /hipster with Python 2.6 I receive:
Python 2.6.9 (unknown, Nov 12 2013, 13:54:48) [GCC 4.7.3] on sunos5 Type "help", "copyright", "credits" or "license" for more information. >>> import string >>> string.lowercase 'abcdefghijklmnopqrstuvwxyz\\xaa\\xb5\\xba\\xdf\\xe0\\xe1\\xe2\\xe3\\xe4\\xe5\\xe6\\xe7\\xe8\\xe9\\xea\\xeb\\xec\\xed\\xee\\xef\\xf0\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf8\\xf9\\xfa\\xfb\\xfc\\xfd\\xfe\\xff' >>> string.uppercase 'ABCDEFGHIJKLMNOPQRSTUVWXYZ\\xc0\\xc1\\xc2\\xc3\\xc4\\xc5\\xc6\\xc7\\xc8\\xc9\\xca\\xcb\\xcc\\xcd\\xce\\xcf\\xd0\\xd1\\xd2\\xd3\\xd4\\xd5\\xd6\\xd8\\xd9\\xda\\xdb\\xdc\\xdd\\xde' >>>
Python 2.7 doesn't have this issue.
python2.7 Python 2.7.3 (default, Dec 7 2013, 10:54:04) [GCC 4.7.3] on sunos5 Type "help", "copyright", "credits" or "license" for more information. >>> import string >>> string.lowercase 'abcdefghijklmnopqrstuvwxyz' >>> string.uppercase 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' >>>
Updated by Alexander Pyhalov over 7 years ago
- Status changed from New to In Progress
- % Done changed from 0 to 100
The real cause was in invalid manipulation with non-ascii symbols in this module. Setting _XOPEN_SOURCE=600 only revealed this. Code called islower/isupper and freinds on symbols with codes > 127. So, it received positives which it didn't expect.
Fixed in https://github.com/OpenIndiana/oi-userland/commit/bf6508bf15502c8de01e9f4132ea9b512ace1b74 .
Updated by Garrett D'Amore over 7 years ago
Note that isupper(), and islower() should return false for non-ASCII characters in the C locale. In other locales YMMV. If Python wants portable handling of this in a non-locale sensitive way, then it should restrict itself to ASCII. That may or may not be the desired behavior.