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

Fraction constructor may accept spaces around '/' #88512

Closed
skirpichev mannequin opened this issue Jun 8, 2021 · 6 comments
Closed

Fraction constructor may accept spaces around '/' #88512

skirpichev mannequin opened this issue Jun 8, 2021 · 6 comments
Labels
3.11 stdlib Python modules in the Lib dir

Comments

@skirpichev
Copy link
Mannequin

skirpichev mannequin commented Jun 8, 2021

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']

    @skirpichev
    Copy link
    Mannequin Author

    skirpichev mannequin commented Jun 8, 2021

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

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

    Tentative patch attached.

    @skirpichev skirpichev mannequin added 3.11 stdlib Python modules in the Lib dir labels Jun 8, 2021
    @vedgar
    Copy link
    Mannequin

    vedgar mannequin commented Jun 9, 2021

    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.

    @skirpichev
    Copy link
    Mannequin Author

    skirpichev mannequin commented Jun 9, 2021

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

    @mdickinson
    Copy link
    Member

    mdickinson commented Jun 9, 2021

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

    See previous discussion in bpo-9574.

    @skirpichev
    Copy link
    Mannequin Author

    skirpichev mannequin commented Jun 9, 2021

    See previous discussion in bpo-9574.

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

    @mdickinson
    Copy link
    Member

    mdickinson commented Sep 4, 2022

    Implemented in #96496.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant