Add __asdict__() to NamedTuple and refine the docs.
Add maxlen support to deque() and fixup docs.
Partially fix __reduce__(). The None as a third arg was no longer supported.
Still needs work on __reduce__() to handle recursive inputs.
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index ab36ad8..939c3ce 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -13,6 +13,7 @@
self.assertEqual(Point.__getitem__, tuple.__getitem__)
self.assertRaises(ValueError, NamedTuple, 'abc%', 'def ghi')
self.assertRaises(ValueError, NamedTuple, 'abc', 'def g%hi')
+ self.assertRaises(ValueError, NamedTuple, 'abc', '__def__ ghi')
NamedTuple('Point0', 'x1 y2') # Verify that numbers are allowed in names
def test_instance(self):
@@ -32,6 +33,7 @@
self.assert_('__weakref__' not in dir(p))
self.assertEqual(p.__fields__, ('x', 'y')) # test __fields__ attribute
self.assertEqual(p.__replace__('x', 1), (1, 22)) # test __replace__ method
+ self.assertEqual(p.__asdict__(), dict(x=11, y=22)) # test __dict__ method
# verify that field string can have commas
Point = NamedTuple('Point', 'x, y')