@@ -2334,7 +2334,8 @@ bufferedrwpair_dealloc(PyObject *op)
23342334}
23352335
23362336static PyObject *
2337- _forward_call (buffered * self , PyObject * name , PyObject * args )
2337+ _forward_call (buffered * self , PyObject * name , PyObject * const * args ,
2338+ Py_ssize_t nargs )
23382339{
23392340 PyObject * func , * ret ;
23402341 if (self == NULL ) {
@@ -2349,107 +2350,171 @@ _forward_call(buffered *self, PyObject *name, PyObject *args)
23492350 return NULL ;
23502351 }
23512352
2352- ret = PyObject_CallObject (func , args );
2353+ ret = PyObject_Vectorcall (func , args , nargs , NULL );
23532354 Py_DECREF (func );
23542355 return ret ;
23552356}
23562357
2358+ /* The optional argument is only passed if it is specified, so that the
2359+ default of the underlying method is used otherwise. */
23572360static PyObject *
2358- bufferedrwpair_read ( PyObject * op , PyObject * args )
2361+ _forward_call_opt ( buffered * self , PyObject * name , PyObject * arg )
23592362{
2360- rwpair * self = rwpair_CAST (op );
2361- return _forward_call (self -> reader , & _Py_ID (read ), args );
2363+ return _forward_call (self , name , & arg , arg != NULL );
23622364}
23632365
2366+ /*[clinic input]
2367+ _io.BufferedRWPair.read
2368+ size: object(c_default="NULL") = -1
2369+ /
2370+ [clinic start generated code]*/
2371+
23642372static PyObject *
2365- bufferedrwpair_peek (PyObject * op , PyObject * args )
2373+ _io_BufferedRWPair_read_impl (rwpair * self , PyObject * size )
2374+ /*[clinic end generated code: output=0668e3c5dbd3e93d input=eddb5e52aba9ebe5]*/
23662375{
2367- rwpair * self = rwpair_CAST (op );
2368- return _forward_call (self -> reader , & _Py_ID (peek ), args );
2376+ return _forward_call_opt (self -> reader , & _Py_ID (read ), size );
23692377}
23702378
2379+ /*[clinic input]
2380+ _io.BufferedRWPair.peek
2381+ size: object(c_default="NULL") = 0
2382+ /
2383+ [clinic start generated code]*/
2384+
23712385static PyObject *
2372- bufferedrwpair_read1 (PyObject * op , PyObject * args )
2386+ _io_BufferedRWPair_peek_impl (rwpair * self , PyObject * size )
2387+ /*[clinic end generated code: output=190a267bd694efa0 input=36af95964bebe355]*/
23732388{
2374- rwpair * self = rwpair_CAST (op );
2375- return _forward_call (self -> reader , & _Py_ID (read1 ), args );
2389+ return _forward_call_opt (self -> reader , & _Py_ID (peek ), size );
23762390}
23772391
2392+ /*[clinic input]
2393+ _io.BufferedRWPair.read1
2394+ size: object(c_default="NULL") = -1
2395+ /
2396+ [clinic start generated code]*/
2397+
23782398static PyObject *
2379- bufferedrwpair_readinto (PyObject * op , PyObject * args )
2399+ _io_BufferedRWPair_read1_impl (rwpair * self , PyObject * size )
2400+ /*[clinic end generated code: output=17ec19608f2bb825 input=9e94db423e490b58]*/
23802401{
2381- rwpair * self = rwpair_CAST (op );
2382- return _forward_call (self -> reader , & _Py_ID (readinto ), args );
2402+ return _forward_call_opt (self -> reader , & _Py_ID (read1 ), size );
23832403}
23842404
2405+ /*[clinic input]
2406+ _io.BufferedRWPair.readinto
2407+ buffer: object
2408+ /
2409+ [clinic start generated code]*/
2410+
23852411static PyObject *
2386- bufferedrwpair_readinto1 (PyObject * op , PyObject * args )
2412+ _io_BufferedRWPair_readinto_impl (rwpair * self , PyObject * buffer )
2413+ /*[clinic end generated code: output=16c86b071015f7a4 input=ccd86ce2666261f7]*/
23872414{
2388- rwpair * self = rwpair_CAST (op );
2389- return _forward_call (self -> reader , & _Py_ID (readinto1 ), args );
2415+ return _forward_call (self -> reader , & _Py_ID (readinto ), & buffer , 1 );
23902416}
23912417
2418+ /*[clinic input]
2419+ _io.BufferedRWPair.readinto1
2420+ buffer: object
2421+ /
2422+ [clinic start generated code]*/
2423+
23922424static PyObject *
2393- bufferedrwpair_write (PyObject * op , PyObject * args )
2425+ _io_BufferedRWPair_readinto1_impl (rwpair * self , PyObject * buffer )
2426+ /*[clinic end generated code: output=f1577b6f54c2b02a input=613d9bf127f88a4a]*/
23942427{
2395- rwpair * self = rwpair_CAST (op );
2396- return _forward_call (self -> writer , & _Py_ID (write ), args );
2428+ return _forward_call (self -> reader , & _Py_ID (readinto1 ), & buffer , 1 );
2429+ }
2430+
2431+ /*[clinic input]
2432+ _io.BufferedRWPair.write
2433+ buffer: object
2434+ /
2435+ [clinic start generated code]*/
2436+
2437+ static PyObject *
2438+ _io_BufferedRWPair_write_impl (rwpair * self , PyObject * buffer )
2439+ /*[clinic end generated code: output=6f7509a747410c68 input=66c602422e3ec36f]*/
2440+ {
2441+ return _forward_call (self -> writer , & _Py_ID (write ), & buffer , 1 );
23972442}
23982443
2444+ /*[clinic input]
2445+ _io.BufferedRWPair.flush
2446+ [clinic start generated code]*/
2447+
23992448static PyObject *
2400- bufferedrwpair_flush (PyObject * op , PyObject * Py_UNUSED (dummy ))
2449+ _io_BufferedRWPair_flush_impl (rwpair * self )
2450+ /*[clinic end generated code: output=0b2dcbe828718d6b input=e853da796ee61df1]*/
24012451{
2402- rwpair * self = rwpair_CAST (op );
2403- return _forward_call (self -> writer , & _Py_ID (flush ), NULL );
2452+ return _forward_call (self -> writer , & _Py_ID (flush ), NULL , 0 );
24042453}
24052454
2455+ /*[clinic input]
2456+ _io.BufferedRWPair.readable
2457+ [clinic start generated code]*/
2458+
24062459static PyObject *
2407- bufferedrwpair_readable (PyObject * op , PyObject * Py_UNUSED (dummy ))
2460+ _io_BufferedRWPair_readable_impl (rwpair * self )
2461+ /*[clinic end generated code: output=615967d4aa58f122 input=0475ed73d0a3167f]*/
24082462{
2409- rwpair * self = rwpair_CAST (op );
2410- return _forward_call (self -> reader , & _Py_ID (readable ), NULL );
2463+ return _forward_call (self -> reader , & _Py_ID (readable ), NULL , 0 );
24112464}
24122465
2466+ /*[clinic input]
2467+ _io.BufferedRWPair.writable
2468+ [clinic start generated code]*/
2469+
24132470static PyObject *
2414- bufferedrwpair_writable (PyObject * op , PyObject * Py_UNUSED (dummy ))
2471+ _io_BufferedRWPair_writable_impl (rwpair * self )
2472+ /*[clinic end generated code: output=c5a43c84e0195c11 input=3cfd44fb4757082f]*/
24152473{
2416- rwpair * self = rwpair_CAST (op );
2417- return _forward_call (self -> writer , & _Py_ID (writable ), NULL );
2474+ return _forward_call (self -> writer , & _Py_ID (writable ), NULL , 0 );
24182475}
24192476
2477+ /*[clinic input]
2478+ _io.BufferedRWPair.close
2479+ [clinic start generated code]*/
2480+
24202481static PyObject *
2421- bufferedrwpair_close (PyObject * op , PyObject * Py_UNUSED (dummy ))
2482+ _io_BufferedRWPair_close_impl (rwpair * self )
2483+ /*[clinic end generated code: output=5924ba5ecc78752a input=4087d69f2d8fc368]*/
24222484{
2423- rwpair * self = rwpair_CAST (op );
24242485 PyObject * exc = NULL ;
2425- PyObject * ret = _forward_call (self -> writer , & _Py_ID (close ), NULL );
2486+ PyObject * ret = _forward_call (self -> writer , & _Py_ID (close ), NULL , 0 );
24262487 if (ret == NULL ) {
24272488 exc = PyErr_GetRaisedException ();
24282489 }
24292490 else {
24302491 Py_DECREF (ret );
24312492 }
2432- ret = _forward_call (self -> reader , & _Py_ID (close ), NULL );
2493+ ret = _forward_call (self -> reader , & _Py_ID (close ), NULL , 0 );
24332494 if (exc != NULL ) {
24342495 _PyErr_ChainExceptions1 (exc );
24352496 Py_CLEAR (ret );
24362497 }
24372498 return ret ;
24382499}
24392500
2501+ /*[clinic input]
2502+ _io.BufferedRWPair.isatty
2503+ [clinic start generated code]*/
2504+
24402505static PyObject *
2441- bufferedrwpair_isatty (PyObject * op , PyObject * Py_UNUSED (dummy ))
2506+ _io_BufferedRWPair_isatty_impl (rwpair * self )
2507+ /*[clinic end generated code: output=d017c621ed879cb7 input=92833e3d60586e14]*/
24422508{
2443- rwpair * self = rwpair_CAST (op );
2444- PyObject * ret = _forward_call (self -> writer , & _Py_ID (isatty ), NULL );
2509+ PyObject * ret = _forward_call (self -> writer , & _Py_ID (isatty ), NULL , 0 );
24452510
24462511 if (ret != Py_False ) {
24472512 /* either True or exception */
24482513 return ret ;
24492514 }
24502515 Py_DECREF (ret );
24512516
2452- return _forward_call (self -> reader , & _Py_ID (isatty ), NULL );
2517+ return _forward_call (self -> reader , & _Py_ID (isatty ), NULL , 0 );
24532518}
24542519
24552520static PyObject *
@@ -2670,20 +2735,20 @@ PyType_Spec _Py_bufferedwriter_spec = {
26702735};
26712736
26722737static PyMethodDef bufferedrwpair_methods [] = {
2673- { "read" , bufferedrwpair_read , METH_VARARGS },
2674- { "peek" , bufferedrwpair_peek , METH_VARARGS },
2675- { "read1" , bufferedrwpair_read1 , METH_VARARGS },
2676- { "readinto" , bufferedrwpair_readinto , METH_VARARGS },
2677- { "readinto1" , bufferedrwpair_readinto1 , METH_VARARGS },
2738+ _IO_BUFFEREDRWPAIR_READ_METHODDEF
2739+ _IO_BUFFEREDRWPAIR_PEEK_METHODDEF
2740+ _IO_BUFFEREDRWPAIR_READ1_METHODDEF
2741+ _IO_BUFFEREDRWPAIR_READINTO_METHODDEF
2742+ _IO_BUFFEREDRWPAIR_READINTO1_METHODDEF
26782743
2679- { "write" , bufferedrwpair_write , METH_VARARGS },
2680- { "flush" , bufferedrwpair_flush , METH_NOARGS },
2744+ _IO_BUFFEREDRWPAIR_WRITE_METHODDEF
2745+ _IO_BUFFEREDRWPAIR_FLUSH_METHODDEF
26812746
2682- { "readable" , bufferedrwpair_readable , METH_NOARGS },
2683- { "writable" , bufferedrwpair_writable , METH_NOARGS },
2747+ _IO_BUFFEREDRWPAIR_READABLE_METHODDEF
2748+ _IO_BUFFEREDRWPAIR_WRITABLE_METHODDEF
26842749
2685- { "close" , bufferedrwpair_close , METH_NOARGS },
2686- { "isatty" , bufferedrwpair_isatty , METH_NOARGS },
2750+ _IO_BUFFEREDRWPAIR_CLOSE_METHODDEF
2751+ _IO_BUFFEREDRWPAIR_ISATTY_METHODDEF
26872752
26882753 {NULL , NULL }
26892754};
0 commit comments