Emit deprecation warning for array typecode u (#7157)

This commit is contained in:
Lee Dogeon authored and GitHub committed 2026-02-15 20:34:19 +09:00
1 parent 4f3d88ce4f
commit 0475671421
2 files changed
+10 -1

No files matched your search

-1
View File
@@ -1255,7 +1255,6 @@ class UnicodeTest(StringTest, unittest.TestCase):
self.assertRaises(ValueError, a.tounicode)
self.assertRaises(ValueError, str, a)
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: DeprecationWarning not triggered
def test_typecode_u_deprecation(self):
with self.assertWarns(DeprecationWarning):
array.array("u")
+10
View File
@@ -35,6 +35,7 @@ mod array {
SaturatedSlice, SequenceIndex, SequenceIndexOp, SliceableSequenceMutOp,
SliceableSequenceOp,
},
stdlib::warnings,
types::{
AsBuffer, AsMapping, AsSequence, Comparable, Constructor, IterNext, Iterable,
PyComparisonOp, Representable, SelfIter,
@@ -645,6 +646,15 @@ mod array {
return Err(vm.new_type_error("array.array() takes no keyword arguments"));
}
if spec == 'u' {
warnings::warn(
vm.ctx.exceptions.deprecation_warning,
"The 'u' type code is deprecated and will be removed in Python 3.16".to_owned(),
1,
vm,
)?;
}
let mut array =
ArrayContentType::from_char(spec).map_err(|err| vm.new_value_error(err))?;