UserString.MutableString has been removed in Python 3.0.
authorBrett Cannon <bcannon@gmail.com>
Thu, 29 May 2008 05:08:50 +0000 (05:08 +0000)
committerBrett Cannon <bcannon@gmail.com>
Thu, 29 May 2008 05:08:50 +0000 (05:08 +0000)
Works on issue #2877. Thanks Quentin Gallet-Gilles for the patch.

Doc/library/userdict.rst
Lib/UserString.py
Lib/test/test_py3kwarn.py
Lib/test/test_userstring.py
Misc/NEWS

index 7d3640153c9ed13aca8d44e44bd84b6ce724a8ee..b0ef645d5e3dbf2d2226b5900100935b18296edb 100644 (file)
@@ -178,6 +178,9 @@ The :mod:`UserString` module defines the following classes:
    mutable object as dictionary key, which would be otherwise very error prone and
    hard to track down.
 
+   .. deprecated:: 2.6
+      The :class:`MutableString` class has been removed in Python 3.0.
+
 In addition to supporting the methods and operations of string and Unicode
 objects (see section :ref:`string-methods`), :class:`UserString` instances
 provide the following attribute:
index 4ef22657601897b58ae6cc137a66497f2aa01b10..446079781a29d7e2b900afa868f753a77f3067bb 100755 (executable)
@@ -146,6 +146,9 @@ class MutableString(UserString, collections.MutableSequence):
 
     A faster and better solution is to rewrite your program using lists."""
     def __init__(self, string=""):
+        from warnings import warnpy3k
+        warnpy3k('the class UserString.MutableString has been removed in '
+                    'Python 3.0', stacklevel=2)
         self.data = string
     def __hash__(self):
         raise TypeError, "unhashable type (it is mutable)"
index d023e4b77c6613b49ea7c07b4d8e41d944b647aa..eed46d1d2431a64bfa1f52f2b80af1bd6fc86b75 100644 (file)
@@ -219,6 +219,14 @@ class TestStdlibRemovals(unittest.TestCase):
                 func = getattr(commands, name)
                 self.assertRaises(DeprecationWarning, func, *([None]*arg_count))
 
+    def test_mutablestring_removal(self):
+        # UserString.MutableString has been removed in 3.0.
+        import UserString
+        with catch_warning(record=False):
+            warnings.filterwarnings("error", ".*MutableString",
+                                    DeprecationWarning)
+            self.assertRaises(DeprecationWarning, UserString.MutableString)
+
 
 def test_main():
     with catch_warning(record=True):
index 06636fcb6438aea661c91a3128de7b98baeb8d34..cae610ef73e08dd90a3c4649e0d6c40c06eb6871 100755 (executable)
@@ -4,8 +4,8 @@
 
 import string
 from test import test_support, string_tests
-
 from UserString import UserString, MutableString
+import warnings
 
 class UserStringTest(
     string_tests.CommonTest,
@@ -135,7 +135,10 @@ class MutableStringTest(UserStringTest):
         self.assertEqual(s, "")
 
 def test_main():
-    test_support.run_unittest(UserStringTest, MutableStringTest)
+    with test_support.catch_warning(record=False):
+        warnings.filterwarnings("ignore", ".*MutableString",
+                                DeprecationWarning)
+        test_support.run_unittest(UserStringTest, MutableStringTest)
 
 if __name__ == "__main__":
     test_main()
index e5f251abaf752610b8fcc73a7f64472023edff0a..b3202b8d34b09c0633ae77edaacc85e2e490b32c 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -63,6 +63,9 @@ Extension Modules
 Library
 -------
 
+Issue #2877 - The UserString.MutableString class has been removed in
+                         Python 3.0.
+
 - Do not close external file objects passed to tarfile.open(mode='w:bz2')
   when the TarFile is closed.