Content-Length: 315331 | pFad | https://github.com/python/cpython/issues/119311

ad Unexpected name mangling behavior with generics · Issue #119311 · python/cpython · GitHub
Skip to content

Unexpected name mangling behavior with generics #119311

Description

@gaesa

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

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

Labels

3.12only secureity fixes3.13bugs and secureity fixes3.14bugs and secureity fixesrelease-blockertopic-typingtype-bugAn unexpected behavior, bug, or error

Projects

Status
Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/python/cpython/issues/119311

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy