New GitHub issue #119311 from gaesa:<br>
<hr>
<pre>
# Bug report
### Bug description:
Name mangling behaves inconsistently when used with generics. Here’s the code to reproduce the issue:
```python
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
</pre>
<hr>
<a href="https://github.com/python/cpython/issues/119311">View on GitHub</a>
<p>Labels: type-bug</p>
<p>Assignee: JelleZijlstra</p>