@@ -2077,12 +2077,16 @@ static PyStructSequence_Desc waitid_result_desc = {
2077
2077
#endif
2078
2078
2079
2079
static PyObject *
2080
- statresult_new (PyTypeObject * type , PyObject * args )
2080
+ statresult_new (PyTypeObject * type , PyObject * args , PyObject * kwargs )
2081
2081
{
2082
2082
PyObject * sequence , * kwds ;
2083
2083
PyStructSequence * result ;
2084
2084
int i ;
2085
2085
2086
+ if (!_PyArg_NoKeywords ("StatResult" , kwargs )) {
2087
+ return NULL ;
2088
+ }
2089
+
2086
2090
/* Remove the cls object from the argument list */
2087
2091
sequence = PyTuple_GetSlice (args , 1 , PyTuple_Size (args ));
2088
2092
if (!sequence ) {
@@ -6249,24 +6253,20 @@ PyDoc_STRVAR(os_sched_param__doc__,
6249
6253
" A scheduling parameter." );
6250
6254
6251
6255
static PyObject *
6252
- os_sched_param (PyTypeObject * type , PyObject * args , PyObject * kwargs )
6256
+ os_sched_param (PyObject * module , PyObject * args , PyObject * kwargs )
6253
6257
{
6254
6258
static char * _keywords [] = {"sched_priority" , NULL };
6255
6259
static const char * _format = "O:sched_param" ;
6256
- PyObject * sequence , * sched_priority , * res ;
6260
+ PyObject * sched_priority , * res ;
6257
6261
6258
- /* Remove the cls object from the argument list */
6259
- sequence = PyTuple_GetSlice (args , 1 , PyTuple_Size (args ));
6260
- if (!sequence ) {
6261
- return NULL ;
6262
- }
6263
- int result = PyArg_ParseTupleAndKeywords (sequence , kwargs , _format , _keywords ,
6262
+ int result = PyArg_ParseTupleAndKeywords (args , kwargs , _format , _keywords ,
6264
6263
& sched_priority );
6265
- Py_DECREF (sequence );
6266
6264
if (!result ) {
6267
6265
return NULL ;
6268
6266
}
6269
- res = PyStructSequence_New ((PyTypeObject * )type );
6267
+ res = PyStructSequence_New (
6268
+ (PyTypeObject * )_posixstate (module )-> SchedParamType
6269
+ );
6270
6270
if (!res ) {
6271
6271
return NULL ;
6272
6272
}
@@ -6275,7 +6275,21 @@ os_sched_param(PyTypeObject *type, PyObject *args, PyObject *kwargs)
6275
6275
return res ;
6276
6276
}
6277
6277
6278
- PyDoc_VAR (os_sched_param__doc__ );
6278
+ static PyObject *
6279
+ sched_param_new (PyTypeObject * type , PyObject * args , PyObject * kwargs ) {
6280
+ PyObject * module = PyState_FindModule (& posixmodule );
6281
+ if (!module ) {
6282
+ return NULL ;
6283
+ }
6284
+ /* Remove the cls object from the argument list */
6285
+ PyObject * sequence = PyTuple_GetSlice (args , 1 , PyTuple_Size (args ));
6286
+ if (!sequence ) {
6287
+ return NULL ;
6288
+ }
6289
+ PyObject * result = os_sched_param (module , args , kwargs );
6290
+ Py_DECREF (sequence );
6291
+ return result ;
6292
+ }
6279
6293
6280
6294
static PyStructSequence_Field sched_param_fields [] = {
6281
6295
{"sched_priority" , "the scheduling priority" },
@@ -13579,16 +13593,6 @@ os__remove_dll_directory_impl(PyObject *module, PyObject *cookie)
13579
13593
13580
13594
#endif
13581
13595
13582
- #if defined(HAVE_SCHED_SETPARAM ) || defined(HAVE_SCHED_SETSCHEDULER ) || defined(POSIX_SPAWN_SETSCHEDULER ) || defined(POSIX_SPAWN_SETSCHEDPARAM )
13583
- static PyMethodDef SchedParamType_dunder_new = {
13584
- "__new__" , (PyCFunction )os_sched_param , METH_VARARGS | METH_KEYWORDS
13585
- };
13586
- #endif
13587
-
13588
- static PyMethodDef StatResultType_dunder_new = {
13589
- "__new__" , (PyCFunction )statresult_new , METH_VARARGS
13590
- };
13591
-
13592
13596
static PyMethodDef posix_methods [] = {
13593
13597
13594
13598
OS_STAT_METHODDEF
@@ -14442,7 +14446,7 @@ static const char * const have_functions[] = {
14442
14446
PyMODINIT_FUNC
14443
14447
INITFUNC (void )
14444
14448
{
14445
- PyObject * m , * v , * dunder_new ;
14449
+ PyObject * m , * v ;
14446
14450
PyObject * list ;
14447
14451
const char * const * trace ;
14448
14452
@@ -14502,13 +14506,8 @@ INITFUNC(void)
14502
14506
_posixstate (m )-> StatResultType = StatResultType ;
14503
14507
14504
14508
/* Add a custom __new__ to the structsequence */
14505
- _posixstate (m )-> structseq_new = (newfunc )PyType_GetSlot ((PyTypeObject * )StatResultType , Py_tp_new );
14506
- dunder_new = PyDescr_NewClassMethod ((PyTypeObject * )StatResultType , & StatResultType_dunder_new );
14507
- if (dunder_new == NULL ) {
14508
- return NULL ;
14509
- }
14510
- PyObject_SetAttrString (StatResultType , "__new__" , dunder_new );
14511
- Py_DECREF (dunder_new );
14509
+ _posixstate (m )-> structseq_new = ((PyTypeObject * )StatResultType )-> tp_new ;
14510
+ ((PyTypeObject * )StatResultType )-> tp_new = statresult_new ;
14512
14511
14513
14512
statvfs_result_desc .name = "os.statvfs_result" ; /* see issue #19209 */
14514
14513
PyObject * StatVFSResultType = (PyObject * )PyStructSequence_NewType (& statvfs_result_desc );
@@ -14538,12 +14537,7 @@ INITFUNC(void)
14538
14537
PyModule_AddObject (m , "sched_param" , SchedParamType );
14539
14538
_posixstate (m )-> SchedParamType = SchedParamType ;
14540
14539
/* Add a custom __new__ to the structsequence */
14541
- dunder_new = PyDescr_NewClassMethod ((PyTypeObject * )SchedParamType , & SchedParamType_dunder_new );
14542
- if (dunder_new == NULL ) {
14543
- return NULL ;
14544
- }
14545
- PyObject_SetAttrString ((PyObject * )SchedParamType , "__new__" , dunder_new );
14546
- Py_DECREF (dunder_new );
14540
+ ((PyTypeObject * )SchedParamType )-> tp_new = sched_param_new ;
14547
14541
#endif
14548
14542
14549
14543
/* initialize TerminalSize_info */
0 commit comments