mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Emit deprecation warning for array typecode u (#7157)
This commit is contained in:
1 parent
4f3d88ce4f
commit
0475671421
2 files changed
+10
-1
No files matched your search
Vendored
-1
@@ -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")
|
||||
|
||||
@@ -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))?;
|
||||
|
||||
|
||||
Reference in new issue
Block a user