Title: PEP 695: Name mangling leaks to surrounding scope · Issue #119395 · python/cpython · GitHub
Open Graph Title: PEP 695: Name mangling leaks to surrounding scope · Issue #119395 · python/cpython
X Title: PEP 695: Name mangling leaks to surrounding scope · Issue #119395 · python/cpython
Description: Bug report % cat leak.py def f(): __foo = 1 class X[T]: ... return __foo f() % python3.12 leak.py Traceback (most recent call last): File "/Users/jelle/py/cpython/leak.py", line 5, in
Open Graph Description: Bug report % cat leak.py def f(): __foo = 1 class X[T]: ... return __foo f() % python3.12 leak.py Traceback (most recent call last): File "/Users/jelle/py/cpython/leak.py", line 5, in
X Description: Bug report % cat leak.py def f(): __foo = 1 class X[T]: ... return __foo f() % python3.12 leak.py Traceback (most recent call last): File "/Users/jelle/py/cpython/leak.py", line 5, in <...
Opengraph URL: https://github.com/python/cpython/issues/119395
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PEP 695: Name mangling leaks to surrounding scope","articleBody":"# Bug report\n\n```\n% cat leak.py \ndef f():\n __foo = 1\n class X[T]: ...\n return __foo\nf()\n% python3.12 leak.py\nTraceback (most recent call last):\n File \"/Users/jelle/py/cpython/leak.py\", line 5, in \u003cmodule>\n f()\n File \"/Users/jelle/py/cpython/leak.py\", line 4, in f\n return __foo\n ^^^^^\nNameError: name '_X__foo' is not defined. Did you mean: '__foo'?\n```\n\nThe PEP 695 implementation of generic classes turns on name mangling for the type parameter scope, but never turns it off afterwards. As a result, all code that appears syntactically after the PEP 695 scope also gets mangling applied to it.\n\nI have a fix for this, but I believe applying it requires updating the magic number, and I'm not sure we can afford to to do that on the 3.12 branch.\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-119399\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/JelleZijlstra","@type":"Person","name":"JelleZijlstra"},"datePublished":"2024-05-22T12:41:35Z","url":"https://github.com/python/cpython/issues/119395"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:5605afb2-6578-4b15-09de-45bf2e461185 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 81C6:335506:D77C1C:123FCA2:6B064FF9 |
| html-safe-nonce | 92195b3917a1e1b2c27f1e890a6de4dc403876d18b2eed57ed628f973f555512 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MUM2OjMzNTUwNjpENzdDMUM6MTIzRkNBMjo2QjA2NEZGOSIsInZpc2l0b3JfaWQiOiIyOTk5MDkzOTE0MTg0ODYzNzM3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 23439852e4307aad77768be30691def001d45df7f979c4c1708f5174089bc8cf |
| hovercard-subject-tag | issue:2310436549 |
| 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/119395/issue_layout |
| twitter:image | https://opengraph.githubassets.com/43319853025149e05d4cf788243b695b071195b0309fb32f056807b4ffd257b4/python/cpython/issues/119395 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/43319853025149e05d4cf788243b695b071195b0309fb32f056807b4ffd257b4/python/cpython/issues/119395 |
| og:image:alt | Bug report % cat leak.py def f(): __foo = 1 class X[T]: ... return __foo f() % python3.12 leak.py Traceback (most recent call last): File "/Users/jelle/py/cpython/leak.py", line 5, in |
| 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 | 772b6997ca4daa0428dd49a25d76052e765555ae560fe9c88517eb828bbd861e |
| 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 | f1f9a08f7c769a37f1dfc18ad43d463c222a7eea |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width