mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
When __slots__ are set to a unicode string, make it work the same as
setting a plain string, ie don't expand to single letter identifiers.
This commit is contained in:
parent
e6bdb9be0e
commit
cbd9ee69ee
3 changed files with 21 additions and 2 deletions
|
@ -1225,13 +1225,29 @@ def slots():
|
|||
raise TestFailed, "[''] slots not caught"
|
||||
class C(object):
|
||||
__slots__ = ["a", "a_b", "_a", "A0123456789Z"]
|
||||
# XXX(nnorwitz): was there supposed to be something tested
|
||||
# from the class above?
|
||||
|
||||
# Test a single string is not expanded as a sequence.
|
||||
class C(object):
|
||||
__slots__ = "abc"
|
||||
c = C()
|
||||
c.abc = 5
|
||||
vereq(c.abc, 5)
|
||||
|
||||
# Test unicode slot names
|
||||
try:
|
||||
unichr
|
||||
unicode
|
||||
except NameError:
|
||||
pass
|
||||
else:
|
||||
# Test a single unicode string is not expanded as a sequence.
|
||||
class C(object):
|
||||
__slots__ = unicode("abc")
|
||||
c = C()
|
||||
c.abc = 5
|
||||
vereq(c.abc, 5)
|
||||
|
||||
# _unicode_to_string used to modify slots in certain circumstances
|
||||
slots = (unicode("foo"), unicode("bar"))
|
||||
class C(object):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue