@@ -105,11 +105,9 @@ fn impl_wrap_common(
105
105
{
106
106
const _LOCATION: & ' static str = concat!(
107
107
stringify!( #cls) , "." , stringify!( #python_name) , "()" ) ;
108
- let _pool = pyo3:: GILPool :: new( ) ;
109
- let _py = _pool. python( ) ;
110
- pyo3:: run_callback( _py, || {
108
+ pyo3:: callback_body!( _py, {
111
109
#slf
112
- pyo3 :: callback :: convert ( _py , #body)
110
+ #body
113
111
} )
114
112
}
115
113
}
@@ -124,16 +122,14 @@ fn impl_wrap_common(
124
122
{
125
123
const _LOCATION: & ' static str = concat!(
126
124
stringify!( #cls) , "." , stringify!( #python_name) , "()" ) ;
127
- let _pool = pyo3:: GILPool :: new( ) ;
128
- let _py = _pool. python( ) ;
129
- pyo3:: run_callback( _py, || {
125
+ pyo3:: callback_body!( _py, {
130
126
#slf
131
127
let _args = _py. from_borrowed_ptr:: <pyo3:: types:: PyTuple >( _args) ;
132
128
let _kwargs: Option <& pyo3:: types:: PyDict > = _py. from_borrowed_ptr_or_opt( _kwargs) ;
133
129
134
130
#body
135
131
136
- pyo3 :: callback :: convert ( _py , _result)
132
+ _result
137
133
} )
138
134
}
139
135
}
@@ -155,17 +151,15 @@ pub fn impl_proto_wrap(cls: &syn::Type, spec: &FnSpec<'_>) -> TokenStream {
155
151
_kwargs: * mut pyo3:: ffi:: PyObject ) -> * mut pyo3:: ffi:: PyObject
156
152
{
157
153
const _LOCATION: & ' static str = concat!( stringify!( #cls) , "." , stringify!( #python_name) , "()" ) ;
158
- let _pool = pyo3:: GILPool :: new( ) ;
159
- let _py = _pool. python( ) ;
160
- pyo3:: run_callback( _py, || {
154
+ pyo3:: callback_body!( _py, {
161
155
let _slf = _py. from_borrowed_ptr:: <pyo3:: PyCell <#cls>>( _slf) ;
162
156
#borrow_self
163
157
let _args = _py. from_borrowed_ptr:: <pyo3:: types:: PyTuple >( _args) ;
164
158
let _kwargs: Option <& pyo3:: types:: PyDict > = _py. from_borrowed_ptr_or_opt( _kwargs) ;
165
159
166
160
#body
167
161
168
- pyo3 :: callback :: convert ( _py , _result)
162
+ _result
169
163
} )
170
164
}
171
165
}
@@ -193,9 +187,7 @@ pub fn impl_wrap_new(cls: &syn::Type, spec: &FnSpec<'_>) -> TokenStream {
193
187
use pyo3:: type_object:: PyTypeInfo ;
194
188
195
189
const _LOCATION: & ' static str = concat!( stringify!( #cls) , "." , stringify!( #python_name) , "()" ) ;
196
- let _pool = pyo3:: GILPool :: new( ) ;
197
- let _py = _pool. python( ) ;
198
- pyo3:: run_callback( _py, || {
190
+ pyo3:: callback_body!( _py, {
199
191
let _args = _py. from_borrowed_ptr:: <pyo3:: types:: PyTuple >( _args) ;
200
192
let _kwargs: Option <& pyo3:: types:: PyDict > = _py. from_borrowed_ptr_or_opt( _kwargs) ;
201
193
@@ -225,16 +217,14 @@ pub fn impl_wrap_class(cls: &syn::Type, spec: &FnSpec<'_>) -> TokenStream {
225
217
_kwargs: * mut pyo3:: ffi:: PyObject ) -> * mut pyo3:: ffi:: PyObject
226
218
{
227
219
const _LOCATION: & ' static str = concat!( stringify!( #cls) , "." , stringify!( #python_name) , "()" ) ;
228
- let _pool = pyo3:: GILPool :: new( ) ;
229
- let _py = _pool. python( ) ;
230
- pyo3:: run_callback( _py, || {
220
+ pyo3:: callback_body!( _py, {
231
221
let _cls = pyo3:: types:: PyType :: from_type_ptr( _py, _cls as * mut pyo3:: ffi:: PyTypeObject ) ;
232
222
let _args = _py. from_borrowed_ptr:: <pyo3:: types:: PyTuple >( _args) ;
233
223
let _kwargs: Option <& pyo3:: types:: PyDict > = _py. from_borrowed_ptr_or_opt( _kwargs) ;
234
224
235
225
#body
236
226
237
- pyo3 :: callback :: convert ( _py , _result)
227
+ _result
238
228
} )
239
229
}
240
230
}
@@ -257,15 +247,13 @@ pub fn impl_wrap_static(cls: &syn::Type, spec: &FnSpec<'_>) -> TokenStream {
257
247
_kwargs: * mut pyo3:: ffi:: PyObject ) -> * mut pyo3:: ffi:: PyObject
258
248
{
259
249
const _LOCATION: & ' static str = concat!( stringify!( #cls) , "." , stringify!( #python_name) , "()" ) ;
260
- let _pool = pyo3:: GILPool :: new( ) ;
261
- let _py = _pool. python( ) ;
262
- pyo3:: run_callback( _py, || {
250
+ pyo3:: callback_body!( _py, {
263
251
let _args = _py. from_borrowed_ptr:: <pyo3:: types:: PyTuple >( _args) ;
264
252
let _kwargs: Option <& pyo3:: types:: PyDict > = _py. from_borrowed_ptr_or_opt( _kwargs) ;
265
253
266
254
#body
267
255
268
- pyo3 :: callback :: convert ( _py , _result)
256
+ _result
269
257
} )
270
258
}
271
259
}
@@ -314,13 +302,10 @@ pub(crate) fn impl_wrap_getter(
314
302
_slf: * mut pyo3:: ffi:: PyObject , _: * mut :: std:: os:: raw:: c_void) -> * mut pyo3:: ffi:: PyObject
315
303
{
316
304
const _LOCATION: & ' static str = concat!( stringify!( #cls) , "." , stringify!( #python_name) , "()" ) ;
317
-
318
- let _pool = pyo3:: GILPool :: new( ) ;
319
- let _py = _pool. python( ) ;
320
- pyo3:: run_callback( _py, || {
305
+ pyo3:: callback_body!( _py, {
321
306
let _slf = _py. from_borrowed_ptr:: <pyo3:: PyCell <#cls>>( _slf) ;
322
307
#borrow_self
323
- pyo3 :: callback :: convert ( _py , #getter_impl)
308
+ #getter_impl
324
309
} )
325
310
}
326
311
} )
@@ -372,14 +357,13 @@ pub(crate) fn impl_wrap_setter(
372
357
_value: * mut pyo3:: ffi:: PyObject , _: * mut :: std:: os:: raw:: c_void) -> pyo3:: libc:: c_int
373
358
{
374
359
const _LOCATION: & ' static str = concat!( stringify!( #cls) , "." , stringify!( #python_name) , "()" ) ;
375
- let _pool = pyo3:: GILPool :: new( ) ;
376
- let _py = _pool. python( ) ;
377
- pyo3:: run_callback( _py, || {
360
+ pyo3:: callback_body!( _py, {
378
361
let _slf = _py. from_borrowed_ptr:: <pyo3:: PyCell <#cls>>( _slf) ;
379
362
#borrow_self
380
363
let _value = _py. from_borrowed_ptr:: <pyo3:: types:: PyAny >( _value) ;
381
364
let _val = pyo3:: FromPyObject :: extract( _value) ?;
382
- pyo3:: callback:: convert( _py, { #setter_impl} )
365
+
366
+ #setter_impl
383
367
} )
384
368
}
385
369
} )
0 commit comments