[Python-checkins] cpython: Undo the deprecation of _asdict().

raymond.hettinger python-checkins at python.org
Sat May 18 09:06:09 CEST 2013


http://hg.python.org/cpython/rev/1b760f926846
changeset:   83823:1b760f926846
user:        Raymond Hettinger <python at rcn.com>
date:        Sat May 18 00:05:20 2013 -0700
summary:
  Undo the deprecation of _asdict().

Backed out changeset c4ca39bece9d

files:
  Doc/library/collections.rst  |  7 ++-----
  Lib/collections/__init__.py  |  3 ---
  Lib/test/test_collections.py |  7 ++-----
  Misc/NEWS                    |  3 ---
  4 files changed, 4 insertions(+), 16 deletions(-)


diff --git a/Doc/library/collections.rst b/Doc/library/collections.rst
--- a/Doc/library/collections.rst
+++ b/Doc/library/collections.rst
@@ -829,9 +829,6 @@
     .. 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 @@
 
     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
 
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -280,9 +280,6 @@
         '''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):
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -217,11 +217,8 @@
         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)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -96,9 +96,6 @@
 
 - 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.

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list