10000 compat fix for test_field_metadata_custom_mapping in test_dataclasses.py · RustPython/RustPython@6c37e8f · GitHub
[go: up one dir, main page]

Skip to content

Commit 6c37e8f

Browse files
hydrogen602youknowone
authored andcommitted
compat fix for test_field_metadata_custom_mapping in test_dataclasses.py
1 parent 4d05416 commit 6c37e8f

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

Lib/test/test_dataclasses.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,8 +1843,6 @@ class C:
18431843
'does not support item assignment'):
18441844
fields(C)[0].metadata['test'] = 3
18451845

1846-
# TODO: RUSTPYTHON
1847-
@unittest.expectedFailure
18481846
def test_field_metadata_custom_mapping(self):
18491847
# Try a custom mapping.
18501848
class SimpleNameSpace:

vm/src/builtins/mappingproxy.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,12 @@ impl Constructor for PyMappingProxy {
9393
))]
9494
impl PyMappingProxy {
9595
fn get_inner(&self, key: PyObjectRef, vm: &VirtualMachine) -> PyResult<Option<PyObjectRef>> {
96-
let opt = match &self.mapping {
97-
MappingProxyInner::Class(class) => key
96+
match &self.mapping {
97+
MappingProxyInner::Class(class) => Ok(key
9898
.as_interned_str(vm)
99-
.and_then(|key| class.attributes.read().get(key).cloned()),
100-
MappingProxyInner::Mapping(mapping) => mapping.mapping().subscript(&*key, vm).ok(),
101-
};
102-
Ok(opt)
99+
.and_then(|key| class.attributes.read().get(key).cloned())),
100+
MappingProxyInner::Mapping(mapping) => mapping.mapping().subscript(&*key, vm).map(Some),
101+
}
103102
}
104103

105104
#[pymethod]

0 commit comments

Comments
 (0)
0