Title: Bug with comprehension inlining + type aliases · Issue #109194 · python/cpython · GitHub
Open Graph Title: Bug with comprehension inlining + type aliases · Issue #109194 · python/cpython
X Title: Bug with comprehension inlining + type aliases · Issue #109194 · python/cpython
Description: 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, y...
Open Graph Description: 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:...
X Description: 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...
Opengraph URL: https://github.com/python/cpython/issues/109194
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug with comprehension inlining + type aliases","articleBody":"Consider this code:\r\n```python\r\nclass C:\r\n T = \"class\"\r\n type Alias3[T] = (T for _ in (1,))\r\n type Alias5[T] = [T for _ in (1,)]\r\n\r\nprint(list(C.Alias3.__value__))\r\nprint(C.Alias5.__value__)\r\n```\r\n\r\nOn current main it produces:\r\n```\r\n[T]\r\n['class']\r\n```\r\nSo 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.\r\n\r\nFound 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.","author":{"url":"https://github.com/JelleZijlstra","@type":"Person","name":"JelleZijlstra"},"datePublished":"2023-09-09T18:20:39.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/109194/cpython/issues/109194"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bbc69884-6971-3ca7-ab74-645d83cc7aad |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B33C:2CE7C7:336B89:429A3F:696B05B1 |
| html-safe-nonce | 4eeaf987c913ca82f4e32e942c68bb254ff646ba278dca9f255f76e3f3886e66 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMzNDOjJDRTdDNzozMzZCODk6NDI5QTNGOjY5NkIwNUIxIiwidmlzaXRvcl9pZCI6IjI2NDE2MjUxNTE5MTE0Mjk1NTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 02022174d4567d27bca98b1feb0339034b59769631e9c36fb1a35fdb49b7f4d0 |
| hovercard-subject-tag | issue:1888834929 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/109194/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5896369f199a9c106c27b03fdf10fc2b5bf3260254c3d3451090e4ae152cee75/python/cpython/issues/109194 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5896369f199a9c106c27b03fdf10fc2b5bf3260254c3d3451090e4ae152cee75/python/cpython/issues/109194 |
| og:image:alt | 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:... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JelleZijlstra |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width