Skip to content

Commit b9c4ab8

Browse files
authored
Merge branch 'RustPython:main' into main
2 parents 9668c2c + 94b38a5 commit b9c4ab8

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

Lib/test/test_fstring.py

-2
Original file line numberDiff line numberDiff line change
@@ -1631,8 +1631,6 @@ def test_empty_format_specifier(self):
16311631
self.assertEqual(f"{x!s:}", "test")
16321632
self.assertEqual(f"{x!r:}", "'test'")
16331633

1634-
# TODO: RUSTPYTHON d[0] error
1635-
@unittest.expectedFailure
16361634
def test_str_format_differences(self):
16371635
d = {
16381636
"a": "string",

common/src/hash.rs

+5
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ pub fn hash_bigint(value: &BigInt) -> PyHash {
139139
fix_sentinel(ret)
140140
}
141141

142+
#[inline]
143+
pub fn hash_usize(data: usize) -> PyHash {
144+
fix_sentinel(mod_int(data as i64))
145+
}
146+
142147
#[inline(always)]
143148
pub fn fix_sentinel(x: PyHash) -> PyHash {
144149
if x == SENTINEL { -2 } else { x }

extra_tests/snippets/builtin_object.py

+7
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,10 @@ class MyObject:
2424
assert not hasattr(obj, 'a')
2525
obj.__dict__ = {'a': 1}
2626
assert obj.a == 1
27+
28+
# Value inside the formatter goes through a different path of resolution.
29+
# Check that it still works all the same
30+
d = {
31+
0: "ab",
32+
}
33+
assert "ab ab" == "{k[0]} {vv}".format(k=d, vv=d[0])

vm/src/dict_inner.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,8 @@ impl DictKey for usize {
993993
*self
994994
}
995995

996-
fn key_hash(&self, vm: &VirtualMachine) -> PyResult<HashValue> {
997-
Ok(vm.state.hash_secret.hash_value(self))
996+
fn key_hash(&self, _vm: &VirtualMachine) -> PyResult<HashValue> {
997+
Ok(hash::hash_usize(*self))
998998
}
999999

10001000
fn key_is(&self, _other: &PyObject) -> bool {

0 commit comments

Comments
 (0)