Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions newsfragments/5883.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
`PyMappingProxy`: allow subclasses during type checking
`PyWeakrefReference`: always allow subclasses during type checking
10 changes: 1 addition & 9 deletions src/types/mappingproxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,15 @@ use crate::types::any::PyAnyMethods;
use crate::types::{PyAny, PyIterator, PyList};
use crate::{ffi, Python};

use std::ffi::c_int;

/// Represents a Python `mappingproxy`.
#[repr(transparent)]
pub struct PyMappingProxy(PyAny);

#[inline]
unsafe fn dict_proxy_check(op: *mut ffi::PyObject) -> c_int {
unsafe { ffi::Py_IS_TYPE(op, &raw mut ffi::PyDictProxy_Type) }
}

pyobject_native_type_core!(
PyMappingProxy,
pyobject_native_static_type_object!(ffi::PyDictProxy_Type),
"types",
"MappingProxyType",
#checkfunction=dict_proxy_check
"MappingProxyType"
);

impl PyMappingProxy {
Expand Down
2 changes: 1 addition & 1 deletion src/types/weakref/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pyobject_native_type!(
"weakref",
"ReferenceType",
#module=Some("weakref"),
#checkfunction=ffi::PyWeakref_CheckRefExact
#checkfunction=ffi::PyWeakref_CheckRef
);

// When targeting alternative or multiple interpreters, it is better to not use the internal API.
Expand Down
Loading