]> granicus.if.org Git - python/commitdiff
Undo the deprecation of _asdict().
authorRaymond Hettinger <python@rcn.com>
Sat, 18 May 2013 07:05:20 +0000 (00:05 -0700)
committerRaymond Hettinger <python@rcn.com>
Sat, 18 May 2013 07:05:20 +0000 (00:05 -0700)
Backed out changeset c4ca39bece9d

Doc/library/collections.rst
Lib/collections/__init__.py
Lib/test/test_collections.py
Misc/NEWS

index 70637687d3348fd2a39607642f8be6ce4bd521fb..96c5aef037102378778c303346db1bdc7a65e6bb 100644 (file)
@@ -829,9 +829,6 @@ field names, the method and attribute names start with an underscore.
     .. versionchanged:: 3.1
         Returns an :class:`OrderedDict` instead of a regular :class:`dict`.
 
-    .. deprecated:: 3.4
-       Use ``vars(nt)`` or ``nt.__dict__`` instead.
-
 .. method:: somenamedtuple._replace(kwargs)
 
     Return a new instance of the named tuple replacing specified fields with new
@@ -848,8 +845,8 @@ field names, the method and attribute names start with an underscore.
 
     A string with the pure Python source code used to create the named
     tuple class.  The source makes the named tuple self-documenting.
-    It can be printed, executed using :func:`exec`, customized, or saved
-    to a file and imported.
+    It can be printed, executed using :func:`exec`, or saved to a file
+    and imported.
 
     .. versionadded:: 3.3
 
index 24daa34b4c263e7a4552219f07585133fb300483..5fd54e8d4cb7f6895e8288a3a4a5ca0e28c16e94 100644 (file)
@@ -280,9 +280,6 @@ class {typename}(tuple):
         '''Return a new OrderedDict which maps field names to their values.
            This method is obsolete.  Use vars(nt) or nt.__dict__ instead.
         '''
-        import warnings
-        warnings.warn('_asdict() is deprecated.  Use vars(nt) instead.',
-                      DeprecationWarning, stacklevel=2)
         return self.__dict__
 
     def __getnewargs__(self):
index 12bd952e3f9b7229653b9418d3038c7e39a4555f..803303125944f152db04b66294bce8a097566c9d 100644 (file)
@@ -217,11 +217,8 @@ class TestNamedTuple(unittest.TestCase):
         self.assertEqual(p, Point._make([11, 22]))                          # test _make classmethod
         self.assertEqual(p._fields, ('x', 'y'))                             # test _fields attribute
         self.assertEqual(p._replace(x=1), (1, 22))                          # test _replace method
-        self.assertEqual(p.__dict__,
-                         OrderedDict([('x', 11), ('y', 22)]))               # test __dict__ attribute
-        self.assertEqual(vars(p), p.__dict__)                               # verify that vars() works
-        with self.assertWarns(DeprecationWarning):                          # check deprecate of _asdict
-            p._asdict()
+        self.assertEqual(p._asdict(), dict(x=11, y=22))                     # test _asdict method
+        self.assertEqual(vars(p), p._asdict())                              # verify that vars() works
 
         try:
             p._replace(x=1, error=2)
index 20bf8b11c2eab8a9f502e01a496e95d59965e197..68902e5c1fe008d46c2533ecbe21a13af1278c28 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -96,9 +96,6 @@ Library
 
 - Issue #15758: Fix FileIO.readall() so it no longer has O(n**2) complexity.
 
-- Deprecated the _asdict() method on named tuples.  Use __dict__ or vars(nt)
-  instead.
-
 - Issue #14596: The struct.Struct() objects now use more compact implementation.
 
 - Issue #17981: Closed socket on error in SysLogHandler.