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

Unparenthesized walrus is not allowed in genexps #86540

Closed
lysnikolaou opened this issue Nov 16, 2020 · 3 comments
Closed

Unparenthesized walrus is not allowed in genexps #86540

lysnikolaou opened this issue Nov 16, 2020 · 3 comments
Labels
3.9 only security fixes 3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@lysnikolaou
Copy link
Member

BPO 42374
Nosy @gvanrossum, @terryjreedy, @lysnikolaou, @pablogsal, @miss-islington
PRs
  • bpo-42374: Allow unparenthesized walrus in genexps #23319
  • [3.9] bpo-42374: Allow unparenthesized walrus in genexps (GH-23319) #23329
  • 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-11-16.23:39:39.790>
    created_at = <Date 2020-11-16.17:43:28.572>
    labels = ['interpreter-core', 'type-bug', '3.9', '3.10']
    title = 'Unparenthesized walrus is not allowed in genexps'
    updated_at = <Date 2020-11-16.23:39:39.789>
    user = 'https://github.com/lysnikolaou'

    bugs.python.org fields:

    activity = <Date 2020-11-16.23:39:39.789>
    actor = 'lys.nikolaou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-11-16.23:39:39.790>
    closer = 'lys.nikolaou'
    components = ['Interpreter Core']
    creation = <Date 2020-11-16.17:43:28.572>
    creator = 'lys.nikolaou'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 42374
    keywords = ['patch', '3.9regression']
    message_count = 3.0
    messages = ['381133', '381178', '381185']
    nosy_count = 5.0
    nosy_names = ['gvanrossum', 'terry.reedy', 'lys.nikolaou', 'pablogsal', 'miss-islington']
    pr_nums = ['23319', '23329']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue42374'
    versions = ['Python 3.9', 'Python 3.10']

    @lysnikolaou
    Copy link
    Member Author

    While a walrus is valid withing generator expressions in 3.8, it's not in 3.9 and onward.

    ➜  cpython git:(master) ✗ python3.8           
    Python 3.8.6 (default, Oct  3 2020, 16:26:47) 
    [GCC 9.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> i = 2
    >>> a = [1, 2, 3, 4]
    >>> (b := i + j for j in a)
    <generator object <genexpr> at 0x7f231e78c740>
    
    
    ➜  cpython git:(master) python3.10              
    Python 3.10.0a1+ (heads/master:b580ed1, Oct 19 2020, 15:52:12) 
    [GCC 9.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> i = 2
    >>> a = [1, 2, 3, 4]
    >>> (b := i + j for j in a)
      File "<stdin>", line 1
        (b := i + j for j in a)
                    ^
    SyntaxError: invalid syntax

    This is a regression introduced by the new parser.

    @lysnikolaou lysnikolaou added 3.9 only security fixes 3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Nov 16, 2020
    @miss-islington
    Copy link
    Contributor

    New changeset cb3e5ed by Lysandros Nikolaou in branch 'master':
    bpo-42374: Allow unparenthesized walrus in genexps (GH-23319)
    cb3e5ed

    @lysnikolaou
    Copy link
    Member Author

    New changeset 2b800ef by Lysandros Nikolaou in branch '3.9':
    bpo-42374: Allow unparenthesized walrus in genexps (GH-23319) (GH-23329)
    2b800ef

    @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
    3.9 only security fixes 3.10 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants