From 33af632914cd0082c991aff0ac9faac05f1049dc Mon Sep 17 00:00:00 2001 From: "Jeong, YunWon" <69878+youknowone@users.noreply.github.com> Date: Mon, 23 Jun 2025 11:43:18 +0900 Subject: [PATCH] fix maketrans (#5824) --- 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 0eeb1ae93..1a8a8f7ee 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -378,8 +378,6 @@ class UnicodeTest(string_tests.CommonTest, 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 a1e53fcbc..d19997c24 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))