Skip to content

string format with 'n' failling with french locales #77652

Closed

Description

@DavidVasseur
BPO 33471
Nosy @ericvsmith, @Licht-T
PRs
  • bpo-33471: Fix invalid numeric formatting with UCS2 separator #6861
  • Superseder
  • bpo-33954: float.format('n') fails with _PyUnicode_CheckConsistency assertion error for locales with non-ascii thousands separator
  • 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 = None
    closed_at = <Date 2020-01-12.02:29:51.342>
    created_at = <Date 2018-05-12.11:30:06.384>
    labels = ['extension-modules', '3.8', 'type-bug', '3.7']
    title = "string format with 'n' failling with french locales"
    updated_at = <Date 2020-01-12.02:29:51.341>
    user = 'https://bugs.python.org/DavidVasseur'

    bugs.python.org fields:

    activity = <Date 2020-01-12.02:29:51.341>
    actor = 'cheryl.sabella'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-01-12.02:29:51.342>
    closer = 'cheryl.sabella'
    components = ['Extension Modules']
    creation = <Date 2018-05-12.11:30:06.384>
    creator = 'David Vasseur'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 33471
    keywords = ['patch']
    message_count = 4.0
    messages = ['316426', '316442', '316456', '316548']
    nosy_count = 3.0
    nosy_names = ['eric.smith', 'licht-t', 'David Vasseur']
    pr_nums = ['6861']
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '33954'
    type = 'behavior'
    url = 'https://bugs.python.org/issue33471'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    Activity

    1. DavidVasseur commented on May 12, 2018

      DavidVasseurmannequin
      MannequinAuthor
      Python 3.6.5 (default, Apr 14 2018, 13:17:30) 
      [GCC 7.3.1 20180406] on linux
      Type "help", "copyright", "credits" or "license" for more information.
      >>> print('{:n}'.format(int(12)))
      12 <-- ok --
      
      >>> import locale
      >>> locale.setlocale(locale.LC_ALL, '')
      'fr_FR.UTF-8'
      >>> print('{:n}'.format(int(12)))
      (empty) <-- error --
      '{:n}'.format(int(12))
      'Àæ' <-- error --
      
      please note that with >999 numbers, it's working fine:
      >>> print('{:n}'.format(int(1000)))
      1 000 <-- ok --
    2. ericvsmith commented on May 13, 2018

      @ericvsmith
      Member

      After locale.setlocale(locale.LC_ALL, ''), what does local.localeconv() return?

    3. DavidVasseur commented on May 13, 2018

      DavidVasseurmannequin
      MannequinAuthor
      >>> locale.localeconv()
      {'int_curr_symbol': 'EUR ', 'currency_symbol': '€', 'mon_decimal_point': ',', 'mon_thousands_sep': '\u202f', 'mon_grouping': [3, 0], 'positive_sign': '', 'negative_sign': '-', 'int_frac_digits': 2, 'frac_digits': 2, 'p_cs_precedes': 0, 'p_sep_by_space': 1, 'n_cs_precedes': 0, 'n_sep_by_space': 1, 'p_sign_posn': 1, 'n_sign_posn': 1, 'decimal_point': ',', 'thousands_sep': '\u202f', 'grouping': [3, 0]}
    4. Licht-T commented on May 14, 2018

      Licht-Tmannequin
      Mannequin

      I am working on this and have found why this is happening.
      I'll make PR in few days.

    5. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)end of life3.8 (EOL)end of lifeextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions