PyType.is_instance/is_subclass should not consume self

This commit is contained in:
messense 2017-06-12 11:56:19 +08:00
parent 6b18ccb50b
commit f07e562251
No known key found for this signature in database
GPG key ID: BB41A8A2C716CCA9

View file

@ -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())
}; };