@@ -94,42 +94,15 @@ pub(crate) fn internal_error_on_minusone(result: c_int) -> PyResult<()> {
9494 }
9595}
9696
97- impl PyAnyHelpers for PyAny {
98- fn is_sequence ( & self ) -> PyResult < bool > {
99- let ptr = self . as_ptr ( ) ;
100- if ptr. is_null ( ) {
101- return Err ( PyErr :: new :: < PySystemError , _ > (
102- "Unable to verify that object is sequence, because ptr to PyAny is null" ,
103- ) ) ;
104- }
105-
106- let v = unsafe { ffi:: PySequence_Check ( ptr) } ;
107- internal_error_on_minusone ( v) ?;
108-
109- Ok ( v != 0 )
110- }
111-
112- fn is_coroutine ( & self ) -> PyResult < bool > {
113- let ptr = self . as_ptr ( ) ;
114- if ptr. is_null ( ) {
115- return Err ( PyErr :: new :: < PySystemError , _ > (
116- "Unable to verify that object is sequence, because ptr to PyAny is null" ,
117- ) ) ;
118- }
119-
120- let v = unsafe { ffi:: PyCoro_CheckExact ( ptr) } ;
121- internal_error_on_minusone ( v) ?;
122-
123- Ok ( v != 0 )
124- }
125- }
126-
127- impl PyAnyHelpers for PyObject {
97+ impl < T > PyAnyHelpers for T
98+ where
99+ T : AsPyPointer ,
100+ {
128101 fn is_sequence ( & self ) -> PyResult < bool > {
129102 let ptr = self . as_ptr ( ) ;
130103 if ptr. is_null ( ) {
131104 return Err ( PyErr :: new :: < PySystemError , _ > (
132- "Unable to verify that object is sequence, because ptr to PyAny is null" ,
105+ "Unable to verify that object is sequence, because ptr is null" ,
133106 ) ) ;
134107 }
135108
@@ -143,7 +116,7 @@ impl PyAnyHelpers for PyObject {
143116 let ptr = self . as_ptr ( ) ;
144117 if ptr. is_null ( ) {
145118 return Err ( PyErr :: new :: < PySystemError , _ > (
146- "Unable to verify that object is sequence , because ptr to PyAny is null" ,
119+ "Unable to verify that object is coroutine , because ptr is null" ,
147120 ) ) ;
148121 }
149122
0 commit comments