PyType.is_instance/is_subclass should not consume self
This commit is contained in:
parent
6b18ccb50b
commit
f07e562251
|
@ -42,7 +42,7 @@ impl PyType {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check whether `self` is subclass of type `T` like Python `issubclass` function
|
/// Check whether `self` is subclass of type `T` like Python `issubclass` function
|
||||||
pub fn is_subclass<T>(self, py: Python) -> PyResult<bool>
|
pub fn is_subclass<T>(&self, py: Python) -> PyResult<bool>
|
||||||
where T: PyTypeObject
|
where T: PyTypeObject
|
||||||
{
|
{
|
||||||
let result = unsafe {
|
let result = unsafe {
|
||||||
|
@ -58,7 +58,7 @@ impl PyType {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether `obj` is an instance of `self`
|
// Check whether `obj` is an instance of `self`
|
||||||
pub fn is_instance<T: ToPyPointer>(self, py: Python, obj: &T) -> PyResult<bool> {
|
pub fn is_instance<T: ToPyPointer>(&self, py: Python, obj: &T) -> PyResult<bool> {
|
||||||
let result = unsafe {
|
let result = unsafe {
|
||||||
ffi::PyObject_IsInstance(obj.as_ptr(), self.as_ptr())
|
ffi::PyObject_IsInstance(obj.as_ptr(), self.as_ptr())
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue