mirror of
https://github.com/python/cpython.git
synced 2025-09-18 22:50:26 +00:00
Issue 1820: structseq objects did not work with the % formatting operator or isinstance(t, tuple).
Orignal patch (without tests) by Leif Walsh.
This commit is contained in:
parent
a01ed03058
commit
c216df9288
4 changed files with 12 additions and 1 deletions
|
@ -26,6 +26,12 @@ class StructSeqTest(unittest.TestCase):
|
||||||
for i in xrange(-len(t), len(t)-1):
|
for i in xrange(-len(t), len(t)-1):
|
||||||
self.assertEqual(t[i], astuple[i])
|
self.assertEqual(t[i], astuple[i])
|
||||||
|
|
||||||
|
def test_tuple_subclass(self):
|
||||||
|
# Issue 1820
|
||||||
|
t = time.localtime()
|
||||||
|
s = ('%s ' * len(t)) % t # This used to fail because t was not a tuple subclass
|
||||||
|
self.assert_(isinstance(t, tuple))
|
||||||
|
|
||||||
def test_repr(self):
|
def test_repr(self):
|
||||||
t = time.gmtime()
|
t = time.gmtime()
|
||||||
self.assert_(repr(t))
|
self.assert_(repr(t))
|
||||||
|
|
|
@ -686,6 +686,7 @@ Wojtek Walczak
|
||||||
Charles Waldman
|
Charles Waldman
|
||||||
Richard Walker
|
Richard Walker
|
||||||
Larry Wall
|
Larry Wall
|
||||||
|
Leif Walsh
|
||||||
Greg Ward
|
Greg Ward
|
||||||
Barry Warsaw
|
Barry Warsaw
|
||||||
Steve Waterbury
|
Steve Waterbury
|
||||||
|
|
|
@ -975,6 +975,10 @@ Library
|
||||||
Extension Modules
|
Extension Modules
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue 1820: structseq objects did not subclass from tuple so they did
|
||||||
|
not pass isinstance(t, tuple) tests and they could not be passed to
|
||||||
|
the % string formatting operator as an input tuple.
|
||||||
|
|
||||||
- _winreg's HKEY object has gained __enter__ and __exit__ methods to support
|
- _winreg's HKEY object has gained __enter__ and __exit__ methods to support
|
||||||
the context manager protocol. The _winreg module also gained a new function
|
the context manager protocol. The _winreg module also gained a new function
|
||||||
``ExpandEnvironmentStrings`` to expand REG_EXPAND_SZ keys.
|
``ExpandEnvironmentStrings`` to expand REG_EXPAND_SZ keys.
|
||||||
|
|
|
@ -460,7 +460,7 @@ static PyTypeObject _struct_sequence_template = {
|
||||||
structseq_methods, /* tp_methods */
|
structseq_methods, /* tp_methods */
|
||||||
NULL, /* tp_members */
|
NULL, /* tp_members */
|
||||||
0, /* tp_getset */
|
0, /* tp_getset */
|
||||||
0, /* tp_base */
|
&PyTuple_Type, /* tp_base */
|
||||||
0, /* tp_dict */
|
0, /* tp_dict */
|
||||||
0, /* tp_descr_get */
|
0, /* tp_descr_get */
|
||||||
0, /* tp_descr_set */
|
0, /* tp_descr_set */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue