From fa71ac969944c6f68fbd837dd48ffa38bc3ef7c3 Mon Sep 17 00:00:00 2001 From: snowapril Date: Sat, 2 Oct 2021 20:01:14 +0900 Subject: [PATCH 1/2] add missing repr on mappingproxy Signed-off-by: snowapril --- vm/src/builtins/mappingproxy.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vm/src/builtins/mappingproxy.rs b/vm/src/builtins/mappingproxy.rs index 225fd1432..27f494222 100644 --- a/vm/src/builtins/mappingproxy.rs +++ b/vm/src/builtins/mappingproxy.rs @@ -137,6 +137,16 @@ impl PyMappingProxy { } } } + #[pymethod(magic)] + fn repr(&self, vm: &VirtualMachine) -> PyResult { + let obj = match &self.mapping { + MappingProxyInner::Dict(d) => d.clone(), + MappingProxyInner::Class(c) => { + PyDict::from_attributes(c.attributes.read().clone(), vm)?.into_pyobject(vm) + } + }; + Ok(format!("mappingproxy({})", vm.to_repr(&obj)?)) + } } impl AsMapping for PyMappingProxy { From 40101b726ce4c9f47e75120d5f723b684b6e2287 Mon Sep 17 00:00:00 2001 From: snowapril Date: Sat, 2 Oct 2021 20:33:47 +0900 Subject: [PATCH 2/2] remove decorators on success tests Signed-off-by: snowapril --- Lib/test/test_dataclasses.py | 2 -- Lib/test/test_pprint.py | 4 ---- 2 files changed, 6 deletions(-) diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py index 3eddc82d5..8dfa1a21c 100644 --- a/Lib/test/test_dataclasses.py +++ b/Lib/test/test_dataclasses.py @@ -52,8 +52,6 @@ class TestCase(unittest.TestCase): class C: x: int = field(default=1, default_factory=int) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_field_repr(self): int_field = field(default=1, init=True, repr=False) int_field.name = "id" diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py index 642d9368d..020a61596 100644 --- a/Lib/test/test_pprint.py +++ b/Lib/test/test_pprint.py @@ -323,8 +323,6 @@ OrderedDict([('the', 0), ('lazy', 7), ('dog', 8)])""") - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_mapping_proxy(self): words = 'the quick brown fox jumped over a lazy dog'.split() d = dict(zip(words, itertools.count())) @@ -657,8 +655,6 @@ frozenset2({0, self.assertEqual(pprint.pformat(dict.fromkeys(keys, 0)), '{%r: 0, %r: 0}' % tuple(sorted(keys, key=id))) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_sort_orderable_and_unorderable_values(self): # Issue 22721: sorted pprints is not stable a = Unorderable()