File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ impl Constructor for PyMappingProxy {
37
37
type Args = PyObjectRef ;
38
38
39
39
fn py_new ( cls : PyTypeRef , mapping : Self :: Args , vm : & VirtualMachine ) -> PyResult {
40
- if !PyMapping :: check ( & mapping)
40
+ if !PyMapping :: check ( & mapping, vm )
41
41
|| mapping. payload_if_subclass :: < PyList > ( vm) . is_some ( )
42
42
|| mapping. payload_if_subclass :: < PyTuple > ( vm) . is_some ( )
43
43
{
Original file line number Diff line number Diff line change @@ -26,10 +26,11 @@ where
26
26
T : Borrow < PyObjectRef > ;
27
27
28
28
impl PyMapping < PyObjectRef > {
29
- pub fn check ( obj : & PyObjectRef ) -> bool {
29
+ pub fn check ( obj : & PyObjectRef , vm : & VirtualMachine ) -> bool {
30
30
obj. class ( )
31
31
. mro_find_map ( |x| x. slots . as_mapping . load ( ) )
32
- . is_some ( )
32
+ . map ( |f| f ( obj, vm) . subscript . is_some ( ) )
33
+ . unwrap_or ( false )
33
34
}
34
35
35
36
pub fn methods ( & self , vm : & VirtualMachine ) -> PyMappingMethods {
@@ -119,7 +120,7 @@ impl IntoPyObject for PyMapping<PyObjectRef> {
119
120
120
121
impl TryFromObject for PyMapping < PyObjectRef > {
121
122
fn try_from_object ( vm : & VirtualMachine , mapping : PyObjectRef ) -> PyResult < Self > {
122
- if Self :: check ( & mapping) {
123
+ if Self :: check ( & mapping, vm ) {
123
124
Ok ( Self :: new ( mapping) )
124
125
} else {
125
126
Err ( vm. new_type_error ( format ! ( "{} is not a mapping object" , mapping. class( ) ) ) )
You can’t perform that action at this time.
0 commit comments