-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
Open
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement
Description
Bug report
Bug description:
Here is the code:
def __a():
print("A")
class A:
def b(self):
__a()
a = A()
a.b()It was expected to show a short message "A". However, I got a NameError:
❯ python3.12 bug\ represent.py
Traceback (most recent call last):
File "/home/PC-Killer/python_work/Demos/bug represent.py", line 11, in <module>
a.b()
File "/home/PC-Killer/python_work/Demos/bug represent.py", line 7, in b
__a()
^^^
NameError: name '_A__a' is not defined
❯ python3.13 bug\ represent.py
Traceback (most recent call last):
File "/home/PC-Killer/python_work/Demos/bug represent.py", line 11, in <module>
a.b()
~~~^^
File "/home/PC-Killer/python_work/Demos/bug represent.py", line 7, in b
__a()
^^^
NameError: name '_A__a' is not definedIt seems that the name had been translated in an unexpected way.
CPython versions tested on:
3.12, 3.13
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancementA feature request or enhancement