Skip to content

Commit 33af632

Browse files
authored
fix maketrans (#5824)
1 parent 0728da5 commit 33af632

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Lib/test/test_unicode.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,6 @@ def test_rindex(self):
378378
self.assertRaises(ValueError, ('a' * 100).rindex, '\U00100304a')
379379
self.assertRaises(ValueError, ('\u0102' * 100).rindex, '\U00100304\u0102')
380380

381-
# TODO: RUSTPYTHON
382-
@unittest.expectedFailure
383381
def test_maketrans_translate(self):
384382
# these work with plain translate()
385383
self.checkequalnofix('bbbc', 'abababc', 'translate',

vm/src/builtins/str.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,10 @@ impl PyStr {
14161416
"string keys in translate table must be of length 1".to_owned(),
14171417
));
14181418
}
1419+
} else {
1420+
return Err(vm.new_type_error(
1421+
"keys in translate table must be strings or integers".to_owned(),
1422+
));
14191423
}
14201424
}
14211425
Ok(new_dict.to_pyobject(vm))

0 commit comments

Comments
 (0)