Issue 11830: "import decimal" fails in Turkish locale
Created on 2011-04-11 22:46 by dmalcolm, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| decimal.py.patch | dmalcolm, 2011-04-11 22:46 | |||
| Messages (6) | |||
|---|---|---|---|
| msg133550 - (view) | Author: Dave Malcolm (dmalcolm) ![]() |
Date: 2011-04-11 22:46 | |
For Python 2 (here with 2.7.1):
$ python -c 'import locale; locale.setlocale(locale.LC_ALL, "tr_TR.UTF-8"); import decimal'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib64/python2.7/decimal.py", line 3715, in <module>
val = globals()[globalname]
KeyError: 'ROUND_CEiLiNG'
The issue is that 'round_ceiling'.upper() is 'ROUND_CEiLiNG' in the Turkish locale, rather than 'ROUND_CEILING', as one might expect.
A workaround for this may be to convert the str instances to unicode
first, then call upper on them, then convert back to str.
This would work since upper() for a unicode instance is locale-independent as
per issue 1528802.
(though there seems to have been some debate there).
Patch attached, though it doesn't yet contain a test case.
Only affects Python 2; with Python 3, the symbols are already stored as unicode internally.
Reported downstream as:
https://bugzilla.redhat.com/show_bug.cgi?id=694928
which has links to various other reports on this
|
|||
| msg133556 - (view) | Author: Roundup Robot (python-dev) ![]() |
Date: 2011-04-12 00:28 | |
New changeset b4b1f557d563 by Raymond Hettinger in branch '2.7': Issue #11830: Remove unnecessary introspection code in the decimal module. http://hg.python.org/cpython/rev/b4b1f557d563 |
|||
| msg133582 - (view) | Author: Alexander Belopolsky (belopolsky) * ![]() |
Date: 2011-04-12 14:01 | |
Shouldn't this be forward ported to 3.3? Even though there is no bug in 3.x, code using an explicit dict is cleaner and more robust than the current code that relies on introspection to find methods that start with '_round_'. |
|||
| msg133588 - (view) | Author: Roundup Robot (python-dev) ![]() |
Date: 2011-04-12 16:06 | |
New changeset f4adc2926bf5 by Raymond Hettinger in branch '2.7': Neaten-up the fix to issue 11830 http://hg.python.org/cpython/rev/f4adc2926bf5 |
|||
| msg133589 - (view) | Author: Raymond Hettinger (rhettinger) * ![]() |
Date: 2011-04-12 16:08 | |
+0 on forward porting |
|||
| msg133640 - (view) | Author: Roundup Robot (python-dev) ![]() |
Date: 2011-04-13 03:09 | |
New changeset f5d5f3f4c081 by Alexander Belopolsky in branch '3.2': Issue #11830: Remove unnecessary introspection code in the decimal module. http://hg.python.org/cpython/rev/f5d5f3f4c081 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:16 | admin | set | github: 56039 |
| 2011-04-13 03:10:42 | belopolsky | set | stage: resolved type: behavior versions: + Python 3.2, Python 3.3 |
| 2011-04-13 03:09:03 | python-dev | set | messages: + msg133640 |
| 2011-04-12 16:13:40 | r.david.murray | set | nosy:
+ mark.dickinson, skrah |
| 2011-04-12 16:08:28 | rhettinger | set | assignee: rhettinger -> belopolsky messages: + msg133589 |
| 2011-04-12 16:06:10 | python-dev | set | messages: + msg133588 |
| 2011-04-12 14:01:43 | belopolsky | set | nosy:
+ belopolsky messages: + msg133582 |
| 2011-04-12 00:28:59 | rhettinger | set | status: open -> closed resolution: fixed |
| 2011-04-12 00:28:03 | python-dev | set | nosy:
+ python-dev messages: + msg133556 |
| 2011-04-11 23:06:20 | rhettinger | set | assignee: rhettinger nosy: + rhettinger |
| 2011-04-11 22:46:56 | dmalcolm | create | |

