diff options
author | Raymond Hettinger <python@rcn.com> | 2008-01-15 03:02:37 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2008-01-15 03:02:37 (GMT) |
commit | c216df9288d03d43462c87dd9ee2ae3c340376a5 (patch) | |
tree | 5ab5cd43a8f75d4dac2f6777e09315b5e78eb453 | |
parent | a01ed0305885d57731c0be69c7c0b10200e48535 (diff) | |
download | cpython-c216df9288d03d43462c87dd9ee2ae3c340376a5.zip cpython-c216df9288d03d43462c87dd9ee2ae3c340376a5.tar.gz cpython-c216df9288d03d43462c87dd9ee2ae3c340376a5.tar.bz2 |
Issue 1820: structseq objects did not work with the % formatting operator or isinstance(t, tuple).
Orignal patch (without tests) by Leif Walsh.
-rw-r--r-- | Lib/test/test_structseq.py | 6 | ||||
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Misc/NEWS | 4 | ||||
-rw-r--r-- | Objects/structseq.c | 2 |
4 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_structseq.py b/Lib/test/test_structseq.py index 83c7ccf..02c2f72 100644 --- a/Lib/test/test_structseq.py +++ b/Lib/test/test_structseq.py @@ -26,6 +26,12 @@ class StructSeqTest(unittest.TestCase): for i in xrange(-len(t), len(t)-1): 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): t = time.gmtime() self.assert_(repr(t)) @@ -686,6 +686,7 @@ Wojtek Walczak Charles Waldman Richard Walker Larry Wall +Leif Walsh Greg Ward Barry Warsaw Steve Waterbury @@ -975,6 +975,10 @@ Library 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 the context manager protocol. The _winreg module also gained a new function ``ExpandEnvironmentStrings`` to expand REG_EXPAND_SZ keys. diff --git a/Objects/structseq.c b/Objects/structseq.c index b6126ba..6b1b590 100644 --- a/Objects/structseq.c +++ b/Objects/structseq.c @@ -460,7 +460,7 @@ static PyTypeObject _struct_sequence_template = { structseq_methods, /* tp_methods */ NULL, /* tp_members */ 0, /* tp_getset */ - 0, /* tp_base */ + &PyTuple_Type, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ |