Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"import decimal" fails in Turkish locale #56039

Closed
davidmalcolm opened this issue Apr 11, 2011 · 6 comments
Closed

"import decimal" fails in Turkish locale #56039

davidmalcolm opened this issue Apr 11, 2011 · 6 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@davidmalcolm
Copy link
Member

BPO 11830
Nosy @rhettinger, @mdickinson, @abalkin, @skrah, @davidmalcolm
Files
  • decimal.py.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/abalkin'
    closed_at = <Date 2011-04-12.00:28:59.876>
    created_at = <Date 2011-04-11.22:46:56.708>
    labels = ['type-bug', 'library']
    title = '"import decimal" fails in Turkish locale'
    updated_at = <Date 2011-04-13.03:10:42.206>
    user = 'https://github.com/davidmalcolm'

    bugs.python.org fields:

    activity = <Date 2011-04-13.03:10:42.206>
    actor = 'belopolsky'
    assignee = 'belopolsky'
    closed = True
    closed_date = <Date 2011-04-12.00:28:59.876>
    closer = 'rhettinger'
    components = ['Library (Lib)']
    creation = <Date 2011-04-11.22:46:56.708>
    creator = 'dmalcolm'
    dependencies = []
    files = ['21622']
    hgrepos = []
    issue_num = 11830
    keywords = ['patch']
    message_count = 6.0
    messages = ['133550', '133556', '133582', '133588', '133589', '133640']
    nosy_count = 6.0
    nosy_names = ['rhettinger', 'mark.dickinson', 'belopolsky', 'skrah', 'dmalcolm', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue11830'
    versions = ['Python 2.7', 'Python 3.2', 'Python 3.3']

    @davidmalcolm
    Copy link
    Member Author

    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 bpo-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

    @davidmalcolm davidmalcolm added the stdlib Python modules in the Lib dir label Apr 11, 2011
    @rhettinger rhettinger self-assigned this Apr 11, 2011
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 12, 2011

    New changeset b4b1f557d563 by Raymond Hettinger in branch '2.7':
    Issue bpo-11830: Remove unnecessary introspection code in the decimal module.
    http://hg.python.org/cpython/rev/b4b1f557d563

    @abalkin
    Copy link
    Member

    abalkin commented Apr 12, 2011

    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_'.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 12, 2011

    New changeset f4adc2926bf5 by Raymond Hettinger in branch '2.7':
    Neaten-up the fix to bpo-11830
    http://hg.python.org/cpython/rev/f4adc2926bf5

    @rhettinger
    Copy link
    Contributor

    +0 on forward porting

    @rhettinger rhettinger assigned abalkin and unassigned rhettinger Apr 12, 2011
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Apr 13, 2011

    New changeset f5d5f3f4c081 by Alexander Belopolsky in branch '3.2':
    Issue bpo-11830: Remove unnecessary introspection code in the decimal module.
    http://hg.python.org/cpython/rev/f5d5f3f4c081

    @abalkin abalkin added the type-bug An unexpected behavior, bug, or error label Apr 13, 2011
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants