From 450fa7cfb342c2e0dada67ddb445fdb78d0f3a96 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Mon, 23 Jun 2025 09:43:22 +0900 Subject: [PATCH] fix maketrans --- Lib/test/test_unicode.py | 2 -- vm/src/builtins/str.rs | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 0eeb1ae936..1a8a8f7ee9 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -378,8 +378,6 @@ def test_rindex(self): self.assertRaises(ValueError, ('a' * 100).rindex, '\U00100304a') self.assertRaises(ValueError, ('\u0102' * 100).rindex, '\U00100304\u0102') - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_maketrans_translate(self): # these work with plain translate() self.checkequalnofix('bbbc', 'abababc', 'translate', diff --git a/vm/src/builtins/str.rs b/vm/src/builtins/str.rs index a1e53fcbcd..d19997c24b 100644 --- a/vm/src/builtins/str.rs +++ b/vm/src/builtins/str.rs @@ -1416,6 +1416,10 @@ impl PyStr { "string keys in translate table must be of length 1".to_owned(), )); } + } else { + return Err(vm.new_type_error( + "keys in translate table must be strings or integers".to_owned(), + )); } } Ok(new_dict.to_pyobject(vm))