diff --git a/tests/snippets/strings.py b/tests/snippets/strings.py index 480500e9f..531e8f83c 100644 --- a/tests/snippets/strings.py +++ b/tests/snippets/strings.py @@ -162,7 +162,7 @@ assert "abc".translate({97: '🎅', 98: None, 99: "xd"}) == "🎅xd" # str.maketrans assert str.maketrans({"a": "abc", "b": None, "c": 33}) == {97: "abc", 98: None, 99: 33} -assert str.maketrans("hello", "world", "rust") == {103: "w", 101: "o", 108: "l", 111: "d", "r": None, "u": None, "s": None, "t": None} +assert str.maketrans("hello", "world", "rust") == {104: 119, 101: 111, 108: 108, 111: 100, 114: None, 117: None, 115: None, 116: None} def try_mutate_str(): word = "word" diff --git a/vm/src/obj/objstr.rs b/vm/src/obj/objstr.rs index a4e6da8c5..6062d1d17 100644 --- a/vm/src/obj/objstr.rs +++ b/vm/src/obj/objstr.rs @@ -884,7 +884,7 @@ impl PyString { let new_dict = vm.context().new_dict(); if to_str.len(vm) == from_str.len(vm) { for (c1, c2) in from_str.value.chars().zip(to_str.value.chars()) { - new_dict.set_item(c1.to_string(), vm.new_str(c2.to_string()), vm)?; + new_dict.set_item(c1 as u32, vm.new_int(c2 as u32), vm)?; } } else { return Err(vm.new_value_error( @@ -893,7 +893,7 @@ impl PyString { } if let OptionalArg::Present(none_str) = none_str { for c in none_str.value.chars() { - new_dict.set_item(c.to_string(), vm.get_none(), vm)?; + new_dict.set_item(c as u32, vm.get_none(), vm)?; } } new_dict.into_pyobject(vm) diff --git a/whats_left.sh b/whats_left.sh index aa79d8d65..66e64f1a3 100755 --- a/whats_left.sh +++ b/whats_left.sh @@ -8,4 +8,4 @@ python3 not_impl_gen.py cd .. -cargo +nightly run -- tests/snippets/whats_left_to_implement.py +cargo run -- tests/snippets/whats_left_to_implement.py \ No newline at end of file