diff options
author | Brett Cannon <bcannon@gmail.com> | 2008-05-29 05:08:50 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2008-05-29 05:08:50 (GMT) |
commit | abb34fe9f3e9a1d4fe2bedee315e360fbf0b2ce5 (patch) | |
tree | 53be4bd55de2d39e02e4314f8c6aa06231b543f2 /Lib | |
parent | 5ec330cb2f1b041ebba6dedb6a02cd27a7e9f3da (diff) | |
download | cpython-abb34fe9f3e9a1d4fe2bedee315e360fbf0b2ce5.zip cpython-abb34fe9f3e9a1d4fe2bedee315e360fbf0b2ce5.tar.gz cpython-abb34fe9f3e9a1d4fe2bedee315e360fbf0b2ce5.tar.bz2 |
UserString.MutableString has been removed in Python 3.0.
Works on issue #2877. Thanks Quentin Gallet-Gilles for the patch.
Diffstat (limited to 'Lib')
-rwxr-xr-x | Lib/UserString.py | 3 | ||||
-rw-r--r-- | Lib/test/test_py3kwarn.py | 8 | ||||
-rwxr-xr-x | Lib/test/test_userstring.py | 7 |
3 files changed, 16 insertions, 2 deletions
diff --git a/Lib/UserString.py b/Lib/UserString.py index 4ef2265..4460797 100755 --- a/Lib/UserString.py +++ b/Lib/UserString.py @@ -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)" diff --git a/Lib/test/test_py3kwarn.py b/Lib/test/test_py3kwarn.py index d023e4b..eed46d1 100644 --- a/Lib/test/test_py3kwarn.py +++ b/Lib/test/test_py3kwarn.py @@ -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): diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py index 06636fc..cae610e 100755 --- a/Lib/test/test_userstring.py +++ b/Lib/test/test_userstring.py @@ -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() |