Skip to content

Fraction constructor may accept spaces around '/' #88512

Description

@skirpichev
mannequin
BPO 44346
Nosy @mdickinson, @vedgar, @skirpichev
Files
  • fraction-spaces.diff
  • 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 = None
    created_at = <Date 2021-06-08.08:29:36.097>
    labels = ['library', '3.11']
    title = "Fraction constructor may accept spaces around '/'"
    updated_at = <Date 2021-06-09.07:04:43.200>
    user = 'https://github.com/skirpichev'

    bugs.python.org fields:

    activity = <Date 2021-06-09.07:04:43.200>
    actor = 'Sergey.Kirpichev'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2021-06-08.08:29:36.097>
    creator = 'Sergey.Kirpichev'
    dependencies = []
    files = ['50097']
    hgrepos = []
    issue_num = 44346
    keywords = ['patch']
    message_count = 5.0
    messages = ['395314', '395379', '395381', '395382', '395384']
    nosy_count = 3.0
    nosy_names = ['mark.dickinson', 'veky', 'Sergey.Kirpichev']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue44346'
    versions = ['Python 3.11']

    Activity

    1. skirpichev commented on Jun 8, 2021

      skirpichevmannequin
      MannequinAuthor

      Per https://bugs.python.org/msg394731 suggestion.

      For instance, mpq_set_str() does support this. Also, gmpy2.mpq().

      Tentative patch attached.

    2. added
      3.11only security fixes
      stdlibStandard Library Python modules in the Lib/ directory
      on Jun 8, 2021
    3. vedgar commented on Jun 9, 2021

      vedgarmannequin
      Mannequin

      Of course, I'm for it. But we have to be consistent... I was surprised to realize complex doesn't accept '2 + 3j' (even though it accepts '(2+3j)', and even '\n2+3j\t'). There are a lot of slippery slopes here (e.g. how about 3_j?). I think that once we allowed _ in integer literals, suddenly we could add more separation between digits than around them in many contexts, and that just seems wrong.

    4. skirpichev commented on Jun 9, 2021

      skirpichevmannequin
      MannequinAuthor

      On Wed, Jun 09, 2021 at 06:18:22AM +0000, Vedran Čačić wrote:

      I was surprised to realize complex doesn't accept '2 + 3j'

      Good catch, probably that should be allowed too.

      e.g. how about 3_j?

      The PEP-515 added '_' as a separator between digits. But the
      imaginary unit is not a digit. For same reason '1_/2' shouldn't
      be allowed for the Rational constructor. (Unfortunately, the
      Decimal class breaks this PEP convention as well as some other,
      see bpo-44267. For example, it accepts things like '1
      ._2'.)

    5. mdickinson commented on Jun 9, 2021

      @mdickinson
      Member

      I was surprised to realize complex doesn't accept '2 + 3j'

      See previous discussion in bpo-9574.

    6. skirpichev commented on Jun 9, 2021

      skirpichevmannequin
      MannequinAuthor

      See previous discussion in bpo-9574.

      Given this, probably spaces around '/' should be disallowed.

    7. transferred this issue fromon Apr 10, 2022
    8. mdickinson commented on Sep 4, 2022

      @mdickinson
      Member

      Implemented in #96496.

    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.11only security fixesstdlibStandard Library Python modules in the Lib/ directory

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions