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

@ -24,6 +24,7 @@ import warnings
import sys, array, io, os
from decimal import Decimal
from fractions import Fraction
from test.support import warnings_helper
try:
from _testbuffer import *
@ -3217,12 +3218,6 @@ class TestBufferProtocol(unittest.TestCase):
nd[0] = (-1, float('nan'))
self.assertNotEqual(memoryview(nd), nd)
# Depends on issue #15625: the struct module does not understand 'u'.
a = array.array('u', 'xyz')
v = memoryview(a)
self.assertNotEqual(a, v)
self.assertNotEqual(v, a)
# Some ctypes format strings are unknown to the struct module.
if ctypes:
# format: "T{>l:x:>l:y:}"
@ -3236,6 +3231,15 @@ class TestBufferProtocol(unittest.TestCase):
self.assertNotEqual(point, a)
self.assertRaises(NotImplementedError, a.tolist)
@warnings_helper.ignore_warnings(category=DeprecationWarning) # gh-80480 array('u')
def test_memoryview_compare_special_cases_deprecated_u_type_code(self):
# Depends on issue #15625: the struct module does not understand 'u'.
a = array.array('u', 'xyz')
v = memoryview(a)
self.assertNotEqual(a, v)
self.assertNotEqual(v, a)
def test_memoryview_compare_ndim_zero(self):
nd1 = ndarray(1729, shape=[], format='@L')