GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — In codecs, function 'normalizestring' should convert both spaces and hyphens to underscores. · Issue #81932 · python/cpython

In codecs, function 'normalizestring' should convert both spaces and hyphens to underscores. #81932

New issue
Copy link
New issue
Copy link
Closed
Closed
In codecs, function 'normalizestring' should convert both spaces and hyphens to underscores.#81932
Copy link
Labels
3.9 (EOL)end of lifeend of lifetopic-unicodetype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

qigangxu
mannequin
opened on Aug 3, 2019
Issue body actions
BPO 37751
Nosy @malemburg, @gpshead, @vstinner, @mark-summerfield, @ezio-melotti, @methane, @miss-islington, @shihai1991, @qigangxu, @akdor1154, @bodograumann
PRs
  • bpo-37751: Fix normalizestring() with hyphens and spaces converted to underscores #15092
  • bpo-37751: Document the change in What's New in Python 3.9 #17997
  • bpo-37751: Document the change in What's New in Python 3.9 #23096
  • bpo-37751: Update codecs.register() doc. #25643
  • [3.9] bpo-37751: Document codecs.lookup() change in What's New in Python 3.9 (GH-23096) #25659
  • [3.9] bpo-37751: Update codecs.register() doc. (GH-25643) #25677
  • 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 2021-04-24.16:55:03.898>
    created_at = <Date 2019-08-03.11:34:13.329>
    labels = ['type-bug', '3.9', 'expert-unicode']
    title = "In codecs, function 'normalizestring' should convert both spaces and hyphens to underscores."
    updated_at = <Date 2022-01-25.00:29:03.446>
    user = 'https://github.com/qigangxu'

    bugs.python.org fields:

    activity = <Date 2022-01-25.00:29:03.446>
    actor = 'gregory.p.smith'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-04-24.16:55:03.898>
    closer = 'shihai1991'
    components = ['Unicode']
    creation = <Date 2019-08-03.11:34:13.329>
    creator = 'qigangxu'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37751
    keywords = ['patch']
    message_count = 31.0
    messages = ['348953', '348954', '348956', '348959', '349448', '350086', '350087', '350155', '359970', '359971', '359972', '359973', '359974', '360005', '391648', '391652', '391653', '391654', '391664', '391666', '391671', '391785', '392077', '392159', '392161', '392178', '395730', '395764', '411536', '411537', '411538']
    nosy_count = 11.0
    nosy_names = ['lemburg', 'gregory.p.smith', 'vstinner', 'mark', 'ezio.melotti', 'methane', 'miss-islington', 'shihai1991', 'qigangxu', 'akdor1154', 'bodograumann']
    pr_nums = ['15092', '17997', '23096', '25643', '25659', '25677']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue37751'
    versions = ['Python 3.9']

    Activity

    Next
    1. qigangxu commented on Aug 3, 2019

      @qigangxu
      qigangxumannequin
      on Aug 3, 2019
      MannequinAuthor
      More actions

      In codecs.c, when _PyCodec_Lookup() call normalizestring(), both spaces and hyphens should be convered to underscores. Not convert spaces to hyphens.

      see:https://github.com/python/peps/blob/master/pep-0100.txt, Codecs (Coder/Decoders) Lookup

    2. qigangxu
      added
      3.9 (EOL)end of lifeend of life
      topic-unicode
      type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
      on Aug 3, 2019
    3. qigangxu commented on Aug 3, 2019

      @qigangxu
      qigangxumannequin
      on Aug 3, 2019
      MannequinAuthor
      More actions

      and I will try to fix it.

    4. shihai1991 commented on Aug 3, 2019

      @shihai1991
      shihai1991
      on Aug 3, 2019
      Member
      More actions

      Hm, there is a bit misleading between desc(https://github.com/python/cpython/blob/master/Python/codecs.c#L53) and the code (https://github.com/python/cpython/blob/master/Python/codecs.c#L74).

    5. qigangxu commented on Aug 3, 2019

      @qigangxu
      qigangxumannequin
      on Aug 3, 2019
      MannequinAuthor
      More actions

      The design and code of the following four places need to be consistent,

      No.1 https://github.com/python/peps/blob/master/pep-0100.txt#L292
      No.2 https://github.com/python/cpython/blob/master/Python/codecs.c#L113
      No.3 https://github.com/python/cpython/blob/master/Python/codecs.c#L53
      No.4 https://github.com/python/cpython/blob/master/Python/codecs.c#74

    6. malemburg commented on Aug 12, 2019

      @malemburg
      malemburg
      on Aug 12, 2019
      Member
      More actions

      Jordon is right. Conversion has to be to underscores, not hyphens. I guess this bug was introduced when the normalization function was converted to C.

    7. vstinner commented on Aug 21, 2019

      @vstinner
      vstinner
      on Aug 21, 2019
      Member
      More actions

      New changeset 20f59fe by Victor Stinner (Jordon Xu) in branch 'master':
      bpo-37751: Fix codecs.lookup() normalization (GH-15092)
      20f59fe

    8. vstinner commented on Aug 21, 2019

      @vstinner
      vstinner
      on Aug 21, 2019
      Member
      More actions

      Thanks for the fix Jordon Xu.

      IMHO this change is not strictly a bugfix, but more like an enhancement. I close the issue.

      If you consider that a backport to Python 3.7 and 3.8 is needed, please say so.

    9. vstinner
      closed this as completedon Aug 21, 2019
    10. qigangxu commented on Aug 22, 2019

      @qigangxu
      qigangxumannequin
      on Aug 22, 2019
      MannequinAuthor
      More actions

      Thanks vstinner. I also don't think it's necessary to backport to the old version. Close this issue is fine.

    11. hroncok commented on Jan 14, 2020

      @hroncok
      hroncokmannequin
      on Jan 14, 2020
      Mannequin
      More actions

      The change is backwards incompatible and a backport would break things. See for example how it breaks latexcodec:

      https://bugzilla.redhat.com/show_bug.cgi?id=1789613#c2

    12. vstinner commented on Jan 14, 2020

      @vstinner
      vstinner
      on Jan 14, 2020
      Member
      More actions

      The change is backwards incompatible and a backport would break things. See for example how it breaks latexcodec:

      I reopen the issue. I proposed PR 17997 to *document* the incompatible change in What's New in Python 3.8. IMO it's a deliberate change and it's correct.

      I rely on Marc-Andre Lemburg who implemented codecs and encodings modules. He wrote: "Jordon is right. Conversion has to be to underscores, not hyphens.".

    13. vstinner
      reopened this on Jan 14, 2020
    14. 9 remaining items

    15. malemburg
      changed the title [-]In codecs, function 'normalizestring' should convert both spaces and hyphens to underscores.[/-] [+]In codecs, function 'normalizestring' should convert both spaces and hyphens to underscores.[/+] on Apr 23, 2021
    16. malemburg commented on Apr 23, 2021

      @malemburg
      malemburg
      on Apr 23, 2021
      Member
      More actions

      On 23.04.2021 07:47, Inada Naoki wrote:

      Inada Naoki <[email protected]> added the comment:

      I think it is too late. Python 3.9 has been released already. Reverting the change is also breaking change.

      PEP-100 says:
      "Search functions are expected to take one argument, the encoding name in all lower case letters and with hyphens and spaces converted to underscores"
      https://www.python.org/dev/peps/pep-0100/#codecs-coder-decoders-lookup

      But codecs.register() says:
      "Search functions are expected to take one argument, being the encoding name in all lower case letters".

      I don't know historical reason why two document are inconsistent.
      https://docs.python.org/3/library/codecs.html#codecs.register

      I guess just an oversight on my part.

      PEP-100 is certainly what I meant and implemented. I should have also
      made it clear in PEP-100 that I meant lower case ASCII letters.

    17. vstinner commented on Apr 23, 2021

      @vstinner
      vstinner
      on Apr 23, 2021
      Member
      More actions

      New changeset 32980fb by Hai Shi in branch 'master':
      bpo-37751: Document codecs.lookup() change in What's New in Python 3.9 (GH-23096)
      32980fb

    18. shihai1991 commented on Apr 24, 2021

      @shihai1991
      shihai1991
      on Apr 24, 2021
      Member
      More actions

      Thanks Marc-Andre for your supplement of PEP-100.
      Thanks Inada, victor for your review and merge.

      After PR-23096 merged, I suggest to close this bpo.
      If there have any other questions, we can reopen it again.

    19. shihai1991
      closed this as completedon Apr 24, 2021
    20. vstinner commented on Apr 27, 2021

      @vstinner
      vstinner
      on Apr 27, 2021
      Member
      More actions

      New changeset 531c810 by Miss Islington (bot) in branch '3.9':
      bpo-37751: Document codecs.lookup() change in What's New in Python 3.9 (GH-23096) (GH-25659)
      531c810

    21. methane commented on Apr 28, 2021

      @methane
      methane
      on Apr 28, 2021
      Member
      More actions

      New changeset 5c84bb5 by Inada Naoki in branch 'master':
      bpo-37751: Update codecs.register() doc. (GH-25643)
      5c84bb5

    22. methane commented on Apr 28, 2021

      @methane
      methane
      on Apr 28, 2021
      Member
      More actions

      New changeset cf9d65c by Miss Islington (bot) in branch '3.9':
      bpo-37751: Update codecs.register() doc. (GH-25643)
      cf9d65c

    23. vstinner commented on Apr 28, 2021

      @vstinner
      vstinner
      on Apr 28, 2021
      Member
      More actions

      Thanks Inada-san for documenting the change in codecs.register() doc!

    24. bodograumann commented on Jun 13, 2021

      @bodograumann
      bodograumannmannequin
      on Jun 13, 2021
      Mannequin
      More actions

      Unfortunately this is not quite finished yet.

      First of all, the change is bigger than what is documented: “Changed in version 3.9: Hyphens and spaces are converted to underscore.“

      In reality, now
      | Normalization works as follows: all non-alphanumeric
      | characters except the dot used for Python package names are
      | collapsed and replaced with a single underscore, e.g. ' -;#'
      | becomes '_'. Leading and trailing underscores are removed.”
      Cf. encodings/init.py

      Secondly, this change breaks lots of iconv codecs with the python-iconv binding. E.g. ASCII//TRANSLIT is now normalized to ascii_translit, which iconv does not understand. Codec names which use hyphens also break and iinm not all of them have aliases in iconv without hyphens.
      Cf. python-iconv #4

      The codecs api feels extremely well-fitting for integrating iconv in python and any alternative I can think of seems unsatisfactory.
      Please advise.

    25. vstinner commented on Jun 13, 2021

      @vstinner
      vstinner
      on Jun 13, 2021
      Member
      More actions

      The codecs api feels extremely well-fitting for integrating iconv in python and any alternative I can think of seems unsatisfactory.

      This issue is now closed, would you mind to open a new issue?

    26. gpshead commented on Jan 25, 2022

      @gpshead
      gpshead
      on Jan 25, 2022
      Member
      More actions

      https://bugs.python.org/issue46508 filed to track fixing the acceptance and use of garbage codec values regression that this caused.

    27. gpshead commented on Jan 25, 2022

      @gpshead
      gpshead
      on Jan 25, 2022
      Member
      More actions

      (note: this might not be the true cause of that issue; though it sounds potentially related - I haven't investigated far enough yet)

    28. gpshead commented on Jan 25, 2022

      @gpshead
      gpshead
      on Jan 25, 2022
      Member
      More actions

      note that Bodo's own followup issue about the breaking change for python-iconv was filed as https://bugs.python.org/issue44723

    29. ezio-melotti
      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.9 (EOL)end of lifeend of lifetopic-unicodetype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions

        You are visitor 01402520 — GeezerVison does not store the pages you look up.
        Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.