gh-80480: Emit DeprecationWarning for array's 'u' type code (#95760)

This commit is contained in:
Hugo van Kemenade 2023-06-11 12:17:35 +03:00 committed by GitHub
parent 3a314f7c3d
commit cc879481e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 10 deletions

View file

@ -13,11 +13,14 @@
import operator
import struct
import sys
import warnings
import array
from array import _array_reconstructor as array_reconstructor
sizeof_wchar = array.array('u').itemsize
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
sizeof_wchar = array.array('u').itemsize
class ArraySubclass(array.array):
@ -93,8 +96,16 @@ def test_empty(self):
UTF32_LE = 20
UTF32_BE = 21
class ArrayReconstructorTest(unittest.TestCase):
def setUp(self):
warnings.filterwarnings(
"ignore",
message="The 'u' type code is deprecated and "
"will be removed in Python 3.16",
category=DeprecationWarning)
def test_error(self):
self.assertRaises(TypeError, array_reconstructor,
"", "b", 0, b"")
@ -1208,10 +1219,16 @@ def test_issue17223(self):
self.assertRaises(ValueError, a.tounicode)
self.assertRaises(ValueError, str, a)
def test_typecode_u_deprecation(self):
with self.assertWarns(DeprecationWarning):
array.array("u")
class UCS4Test(UnicodeTest):
typecode = 'w'
minitemsize = 4
class NumberTest(BaseTest):
def test_extslice(self):