summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorŽiga Seilnacht <ziga.seilnacht@gmail.com>2007-03-14 12:24:09 (GMT)
committerŽiga Seilnacht <ziga.seilnacht@gmail.com>2007-03-14 12:24:09 (GMT)
commit71436f022996b82b2e2518ee5dd08d1a2923eaae (patch)
tree316053c7be3c8b9a6b0445884320b03ec712d847 /Lib/test
parentf66b6039c11fb8f9162867afb7e6574652637a7b (diff)
downloadcpython-71436f022996b82b2e2518ee5dd08d1a2923eaae.zip
cpython-71436f022996b82b2e2518ee5dd08d1a2923eaae.tar.gz
cpython-71436f022996b82b2e2518ee5dd08d1a2923eaae.tar.bz2
Patch #1680015: Don't modify __slots__ tuple if it contains an unicode
name. Remove a reference leak that happened if the name could not be converted to string. Will backport.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_descr.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 7e2313d..71f4ec4 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1226,6 +1226,29 @@ def slots():
class C(object):
__slots__ = ["a", "a_b", "_a", "A0123456789Z"]
+ # Test unicode slot names
+ try:
+ unichr
+ except NameError:
+ pass
+ else:
+ # _unicode_to_string used to modify slots in certain circumstances
+ slots = (unicode("foo"), unicode("bar"))
+ class C(object):
+ __slots__ = slots
+ x = C()
+ x.foo = 5
+ vereq(x.foo, 5)
+ veris(type(slots[0]), unicode)
+ # this used to leak references
+ try:
+ class C(object):
+ __slots__ = [unichr(128)]
+ except (TypeError, UnicodeEncodeError):
+ pass
+ else:
+ raise TestFailed, "[unichr(128)] slots not caught"
+
# Test leaks
class Counted(object):
counter = 0 # counts the number of instances alive