mirror of
https://github.com/python/cpython.git
synced 2025-11-01 14:11:41 +00:00
gh-80480: Emit DeprecationWarning for array's 'u' type code (#95760)
This commit is contained in:
parent
3a314f7c3d
commit
cc879481e2
7 changed files with 48 additions and 10 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue