summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2002-06-20 22:23:15 (GMT)
committerRaymond Hettinger <python@rcn.com>2002-06-20 22:23:15 (GMT)
commit0ae0c076615934ed237b412464b49b58c60c0644 (patch)
tree207ecdd2c40c541dfaffb657a7e9b16d6bada6e1 /Lib/test/test_descr.py
parent1d1e1dba12d48d6d93b09e4bd140962b4c110dfb (diff)
downloadcpython-0ae0c076615934ed237b412464b49b58c60c0644.zip
cpython-0ae0c076615934ed237b412464b49b58c60c0644.tar.gz
cpython-0ae0c076615934ed237b412464b49b58c60c0644.tar.bz2
SF 569257 -- Name mangle double underscored variable names in __slots__.
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 2129a7b..dca8ea1 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -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):