@@ -16122,6 +16122,8 @@ typedef struct {
16122
16122
#endif
16123
16123
} ScandirIterator ;
16124
16124
16125
+ #define ScandirIterator_CAST (op ) ((ScandirIterator *)(op))
16126
+
16125
16127
#ifdef MS_WINDOWS
16126
16128
16127
16129
static int
@@ -16145,8 +16147,9 @@ ScandirIterator_closedir(ScandirIterator *iterator)
16145
16147
}
16146
16148
16147
16149
static PyObject *
16148
- ScandirIterator_iternext (ScandirIterator * iterator )
16150
+ ScandirIterator_iternext (PyObject * op )
16149
16151
{
16152
+ ScandirIterator * iterator = ScandirIterator_CAST (op );
16150
16153
WIN32_FIND_DATAW * file_data = & iterator -> file_data ;
16151
16154
BOOL success ;
16152
16155
PyObject * entry ;
@@ -16216,8 +16219,9 @@ ScandirIterator_closedir(ScandirIterator *iterator)
16216
16219
}
16217
16220
16218
16221
static PyObject *
16219
- ScandirIterator_iternext (ScandirIterator * iterator )
16222
+ ScandirIterator_iternext (PyObject * op )
16220
16223
{
16224
+ ScandirIterator * iterator = ScandirIterator_CAST (op );
16221
16225
struct dirent * direntp ;
16222
16226
Py_ssize_t name_len ;
16223
16227
int is_dot ;
@@ -16269,40 +16273,43 @@ ScandirIterator_iternext(ScandirIterator *iterator)
16269
16273
#endif
16270
16274
16271
16275
static PyObject *
16272
- ScandirIterator_close (ScandirIterator * self , PyObject * args )
16276
+ ScandirIterator_close (PyObject * op , PyObject * Py_UNUSED ( args ) )
16273
16277
{
16278
+ ScandirIterator * self = ScandirIterator_CAST (op );
16274
16279
ScandirIterator_closedir (self );
16275
16280
Py_RETURN_NONE ;
16276
16281
}
16277
16282
16278
16283
static PyObject *
16279
- ScandirIterator_enter (PyObject * self , PyObject * args )
16284
+ ScandirIterator_enter (PyObject * self , PyObject * Py_UNUSED ( args ) )
16280
16285
{
16281
16286
return Py_NewRef (self );
16282
16287
}
16283
16288
16284
16289
static PyObject *
16285
- ScandirIterator_exit (ScandirIterator * self , PyObject * args )
16290
+ ScandirIterator_exit (PyObject * op , PyObject * Py_UNUSED ( args ) )
16286
16291
{
16292
+ ScandirIterator * self = ScandirIterator_CAST (op );
16287
16293
ScandirIterator_closedir (self );
16288
16294
Py_RETURN_NONE ;
16289
16295
}
16290
16296
16291
16297
static void
16292
- ScandirIterator_finalize (ScandirIterator * iterator )
16298
+ ScandirIterator_finalize (PyObject * op )
16293
16299
{
16294
-
16300
+ ScandirIterator * iterator = ScandirIterator_CAST ( op );
16295
16301
/* Save the current exception, if any. */
16296
16302
PyObject * exc = PyErr_GetRaisedException ();
16297
16303
16298
16304
if (!ScandirIterator_is_closed (iterator )) {
16299
16305
ScandirIterator_closedir (iterator );
16300
16306
16301
- if (PyErr_ResourceWarning ((PyObject * )iterator , 1 ,
16302
- "unclosed scandir iterator %R" , iterator )) {
16307
+ if (PyErr_ResourceWarning<
8000
/span>(op , 1 ,
16308
+ "unclosed scandir iterator %R" , iterator ))
16309
+ {
16303
16310
/* Spurious errors can appear at shutdown */
16304
16311
if (PyErr_ExceptionMatches (PyExc_Warning )) {
16305
- PyErr_WriteUnraisable (( PyObject * ) iterator );
16312
+ PyErr_WriteUnraisable (op );
16306
16313
}
16307
16314
}
16308
16315
}
@@ -16314,10 +16321,11 @@ ScandirIterator_finalize(ScandirIterator *iterator)
16314
16321
}
16315
16322
16316
16323
static void
16317
- ScandirIterator_dealloc (ScandirIterator * iterator )
16324
+ ScandirIterator_dealloc (PyObject * op )
16318
16325
{
16326
+ ScandirIterator * iterator = ScandirIterator_CAST (op );
16319
16327
PyTypeObject * tp = Py_TYPE (iterator );
16320
- if (PyObject_CallFinalizerFromDealloc (( PyObject * ) iterator ) < 0 )
16328
+ if (PyObject_CallFinalizerFromDealloc (op ) < 0 )
16321
16329
return ;
16322
16330
16323
16331
freefunc free_func = PyType_GetSlot (tp , Py_tp_free );
@@ -16326,9 +16334,9 @@ ScandirIterator_dealloc(ScandirIterator *iterator)
16326
16334
}
16327
16335
16328
16336
static PyMethodDef ScandirIterator_methods [] = {
16329
- {"__enter__" , ( PyCFunction ) ScandirIterator_enter , METH_NOARGS },
16330
- {"__exit__" , ( PyCFunction ) ScandirIterator_exit , METH_VARARGS },
16331
- {"close" , ( PyCFunction ) ScandirIterator_close , METH_NOARGS },
16337
+ {"__enter__" , ScandirIterator_enter , METH_NOARGS },
16338
+ {"__exit__" , ScandirIterator_exit , METH_VARARGS },
16339
+ {"close" , ScandirIterator_close , METH_NOARGS },
16332
16340
{NULL }
16333
16341
};
16334
16342
0 commit comments