mirror of
https://github.com/python/cpython.git
synced 2025-10-06 23:21:06 +00:00
bpo-38916: array.array: remove fromstring() and tostring() (GH-17487)
array.array: Remove tostring() and fromstring() methods. They were aliases to tobytes() and frombytes(), deprecated since Python 3.2.
This commit is contained in:
parent
a1838ec259
commit
0131aba5ae
6 changed files with 9 additions and 140 deletions
|
@ -426,26 +426,6 @@ class BaseTest:
|
|||
b.fromlist(a.tolist())
|
||||
self.assertEqual(a, b)
|
||||
|
||||
def test_tofromstring(self):
|
||||
# Warnings not raised when arguments are incorrect as Argument Clinic
|
||||
# handles that before the warning can be raised.
|
||||
nb_warnings = 2
|
||||
with warnings.catch_warnings(record=True) as r:
|
||||
warnings.filterwarnings("always",
|
||||
message=r"(to|from)string\(\) is deprecated",
|
||||
category=DeprecationWarning)
|
||||
a = array.array(self.typecode, 2*self.example)
|
||||
b = array.array(self.typecode)
|
||||
self.assertRaises(TypeError, a.tostring, 42)
|
||||
self.assertRaises(TypeError, b.fromstring)
|
||||
self.assertRaises(TypeError, b.fromstring, 42)
|
||||
b.fromstring(a.tostring())
|
||||
self.assertEqual(a, b)
|
||||
if a.itemsize>1:
|
||||
self.assertRaises(ValueError, b.fromstring, "x")
|
||||
nb_warnings += 1
|
||||
self.assertEqual(len(r), nb_warnings)
|
||||
|
||||
def test_tofrombytes(self):
|
||||
a = array.array(self.typecode, 2*self.example)
|
||||
b = array.array(self.typecode)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue