[Python-checkins] r63767 - in python/trunk: Doc/library/userdict.rst Lib/UserString.py Lib/test/test_py3kwarn.py Lib/test/test_userstring.py Misc/NEWS
brett.cannon
python-checkins at python.org
Thu May 29 07:08:51 CEST 2008
Author: brett.cannon
Date: Thu May 29 07:08:50 2008
New Revision: 63767
Log:
UserString.MutableString has been removed in Python 3.0.
Works on issue #2877. Thanks Quentin Gallet-Gilles for the patch.
Modified:
python/trunk/Doc/library/userdict.rst
python/trunk/Lib/UserString.py
python/trunk/Lib/test/test_py3kwarn.py
python/trunk/Lib/test/test_userstring.py
python/trunk/Misc/NEWS
Modified: python/trunk/Doc/library/userdict.rst
==============================================================================
--- python/trunk/Doc/library/userdict.rst (original)
+++ python/trunk/Doc/library/userdict.rst Thu May 29 07:08:50 2008
@@ -178,6 +178,9 @@
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:
Modified: python/trunk/Lib/UserString.py
==============================================================================
--- python/trunk/Lib/UserString.py (original)
+++ python/trunk/Lib/UserString.py Thu May 29 07:08:50 2008
@@ -146,6 +146,9 @@
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)"
Modified: python/trunk/Lib/test/test_py3kwarn.py
==============================================================================
--- python/trunk/Lib/test/test_py3kwarn.py (original)
+++ python/trunk/Lib/test/test_py3kwarn.py Thu May 29 07:08:50 2008
@@ -219,6 +219,14 @@
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):
Modified: python/trunk/Lib/test/test_userstring.py
==============================================================================
--- python/trunk/Lib/test/test_userstring.py (original)
+++ python/trunk/Lib/test/test_userstring.py Thu May 29 07:08:50 2008
@@ -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 @@
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()
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Thu May 29 07:08:50 2008
@@ -63,6 +63,9 @@
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.
More information about the Python-checkins
mailing list