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 — Bug with comprehension inlining + type aliases · Issue #109194 · python/cpython

Bug with comprehension inlining + type aliases #109194

New issue
Copy link
New issue
Copy link
Closed
#109196
Closed
Bug with comprehension inlining + type aliases#109194
#109196
Copy link
Assignees
carljm
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@JelleZijlstra
JelleZijlstra
opened on Sep 9, 2023
Issue body actions

Consider this code:

class C:
    T = "class"
    type Alias3[T] = (T for _ in (1,))
    type Alias5[T] = [T for _ in (1,)]

print(list(C.Alias3.__value__))
print(C.Alias5.__value__)

On current main it produces:

[T]
['class']

So if you use a genexp, you get the T type parameter, but if you use a listcomp, you get the class variable. I think the genexp behavior is right; the comprehension should never see the class scope.

Found this while looking into #109118. Filing this separately as the symptom is different, but I suspect we'll have to solve both simultaneously. cc @carljm for PEP 709.

Reacted by Carl Meyer

Activity

  1. sunmy2019
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Sep 9, 2023
  2. JelleZijlstra
    added a commit that references this issue on Sep 9, 2023

    pythongh-109118: Disallow nested scopes within PEP 695 scopes within …

    This issue will close once commit d7be560 is merged into the 'master' branch.
    d7be560
  3. carljm
    self-assigned this
    on Sep 11, 2023
  4. JelleZijlstra
    closed this as completedin #109196on Sep 12, 2023
  5. JelleZijlstra
    added a commit that references this issue on Sep 12, 2023

    gh-109118: Disallow nested scopes within PEP 695 scopes within classes (

    This issue will close once commit b88d9e7 is merged into the 'main' branch.
    b88d9e7
  6. miss-islington
    added a commit that references this issue on Sep 12, 2023

    pythongh-109118: Disallow nested scopes within PEP 695 scopes within …

    This issue will close once commit 0dc03f4 is merged into the 'master' branch.
    0dc03f4
  7. Yhg1s
    added a commit that references this issue on Sep 12, 2023

    [3.12] gh-109118: Disallow nested scopes within PEP 695 scopes within…

    This issue will close once commit 8208657 is merged into the 'main' branch.
    8208657
  8. vstinner
    added a commit that references this issue on Sep 13, 2023

    pythongh-109118: Disallow nested scopes within PEP 695 scopes within …

    This issue will close once commit cc1f90e is merged into the 'main' branch.
    cc1f90e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @carljm
    carljm

Labels

type-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.