File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -191,9 +191,15 @@ batched_next(batchedobject *bo)
191191 PyObject * item ;
192192 PyObject * result ;
193193
194+ #ifdef Py_GIL_DISABLED
195+ if (it == NULL ) {
196+ return NULL ;
197+ }
198+ #else
194199 if (n < 0 ) {
195200 return NULL ;
196201 }
202+ #endif
197203 result = PyTuple_New (n );
198204 if (result == NULL ) {
199205 return NULL ;
@@ -213,19 +219,31 @@ batched_next(batchedobject *bo)
213219 if (PyErr_Occurred ()) {
214220 if (!PyErr_ExceptionMatches (PyExc_StopIteration )) {
215221 /* Input raised an exception other than StopIteration */
222+ #ifdef Py_GIL_DISABLED
216223 FT_ATOMIC_STORE_SSIZE_RELAXED (bo -> batch_size , -1 );
224+ #else
225+ Py_CLEAR (bo -> it );
226+ #endif
217227 Py_DECREF (result );
218228 return NULL ;
219229 }
220230 PyErr_Clear ();
221231 }
222232 if (i == 0 ) {
233+ #ifdef Py_GIL_DISABLED
223234 FT_ATOMIC_STORE_SSIZE_RELAXED (bo -> batch_size , -1 );
235+ #else
236+ Py_CLEAR (bo -> it );
237+ #endif
224238 Py_DECREF (result );
225239 return NULL ;
226240 }
227241 if (bo -> strict ) {
242+ #ifdef Py_GIL_DISABLED
228243 FT_ATOMIC_STORE_SSIZE_RELAXED (bo -> batch_size , -1 );
244+ #else
245+ Py_CLEAR (bo -> it );
246+ #endif
229247 Py_DECREF (result );
230248 PyErr_SetString (PyExc_ValueError , "batched(): incomplete batch" );
231249 return NULL ;
You can’t perform that action at this time.
0 commit comments