mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
SF 569257 -- Name mangle double underscored variable names in __slots__.
This commit is contained in:
parent
1d1e1dba12
commit
0ae0c07661
4 changed files with 49 additions and 7 deletions
|
@ -1060,6 +1060,24 @@ def slots():
|
|||
vereq(x.b, 2)
|
||||
vereq(x.c, 3)
|
||||
|
||||
class C4(object):
|
||||
"""Validate name mangling"""
|
||||
__slots__ = ['__a']
|
||||
def __init__(self, value):
|
||||
self.__a = value
|
||||
def get(self):
|
||||
return self.__a
|
||||
x = C4(5)
|
||||
verify(not hasattr(x, '__dict__'))
|
||||
verify(not hasattr(x, '__a'))
|
||||
vereq(x.get(), 5)
|
||||
try:
|
||||
x.__a = 6
|
||||
except AttributeError:
|
||||
pass
|
||||
else:
|
||||
raise TestFailed, "Double underscored names not mangled"
|
||||
|
||||
# Make sure slot names are proper identifiers
|
||||
try:
|
||||
class C(object):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue