Title: Unexpected name mangling behavior with generics · Issue #119311 · python/cpython · GitHub
Open Graph Title: Unexpected name mangling behavior with generics · Issue #119311 · python/cpython
X Title: Unexpected name mangling behavior with generics · Issue #119311 · python/cpython
Description: Bug report Bug description: Name mangling behaves inconsistently when used with generics. Here’s the code to reproduce the issue: class __Foo(type): pass class Bar[T](metaclass=__Foo): pass This raises NameError: name '_Bar__Foo' is not ...
Open Graph Description: Bug report Bug description: Name mangling behaves inconsistently when used with generics. Here’s the code to reproduce the issue: class __Foo(type): pass class Bar[T](metaclass=__Foo): pass This ra...
X Description: Bug report Bug description: Name mangling behaves inconsistently when used with generics. Here’s the code to reproduce the issue: class __Foo(type): pass class Bar[T](metaclass=__Foo): pass This ra...
Opengraph URL: https://github.com/python/cpython/issues/119311
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unexpected name mangling behavior with generics","articleBody":"# Bug report\n\n### Bug description:\n\nName mangling behaves inconsistently when used with generics. Here’s the code to reproduce the issue:\n```python\nclass __Foo(type):\n pass\n\n\nclass Bar[T](metaclass=__Foo):\n pass\n```\n\nThis raises `NameError: name '_Bar__Foo' is not defined`. However, removing the `[T]` results in the error disappearing. This suggests that the name mangling behavior is inconsistent when generics are involved. This behavior seems to be a bug, as it would be expected for the name mangling to either always occur or never occur, regardless of whether generics are used.\n\n### CPython versions tested on:\n\n3.12\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-119464\n* gh-119643\n* gh-119644\n* gh-125771\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/gaesa","@type":"Person","name":"gaesa"},"datePublished":"2024-05-21T14:43:26Z","url":"https://github.com/python/cpython/issues/119311"}
| 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:eeed62f4-95c2-ffae-cb72-d356d248dce8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BC92:8007E:EE5BB6:13DAF18:6B064E0C |
| html-safe-nonce | be1488664b2edf9435d9c6418b8550e99b40e2fdcd1cd74710d359d530397b04 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzkyOjgwMDdFOkVFNUJCNjoxM0RBRjE4OjZCMDY0RTBDIiwidmlzaXRvcl9pZCI6IjEyMjIwMzAzNjA1Nzg1MTAzNDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 25d40bde689c95d256fc7c29089b312cb09be408784dad8e9000e242d8931678 |
| hovercard-subject-tag | issue:2308478032 |
| 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/119311/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d649d15db00220a10cd9454f0aae10e1012f01bec3525f73c7ad037a5d696a90/python/cpython/issues/119311 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d649d15db00220a10cd9454f0aae10e1012f01bec3525f73c7ad037a5d696a90/python/cpython/issues/119311 |
| og:image:alt | Bug report Bug description: Name mangling behaves inconsistently when used with generics. Here’s the code to reproduce the issue: class __Foo(type): pass class Bar[T](metaclass=__Foo): pass This ra... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gaesa |
| 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 | canary-1 |
| 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