@@ -121,9 +121,13 @@ MUST_INLINE static int _PyTruffleArg_ParseTupleAndKeywords(PyObject *argv, PyObj
121
121
case 'y' :
122
122
arg = PyTruffle_GetArg (v , kwds , kwdnames , rest_keywords_only );
123
123
if (format [format_idx + 1 ] == '*' ) {
124
- format_idx ++ ; // skip over '*'
125
- PyErr_Format (PyExc_TypeError , "%c* not supported" , c );
126
- return 0 ;
124
+ Py_buffer * p = PyTruffleVaArg (poly_args , offset , va , Py_buffer * );
125
+ const char * buf ;
126
+ format_idx ++ ; // skip over '*'
127
+ if (getbuffer (arg , p , & buf ) < 0 ) {
128
+ PyErr_Format (PyExc_TypeError , "expected bytes, got %R" , Py_TYPE (arg ));
129
+ return 0 ;
130
+ }
127
131
} else if (arg == Py_None ) {
128
132
if (c == 'z' ) {
129
133
PyTruffle_WriteOut (poly_args , offset , va , const char * , NULL );
@@ -374,7 +378,6 @@ int _PyArg_VaParseTupleAndKeywords_SizeT(PyObject *argv, PyObject *kwds, const c
374
378
return _PyTruffleArg_ParseTupleAndKeywords (argv , kwds , format , kwdnames , va , NULL , 0 );
375
379
}
376
380
377
-
378
381
int PyArg_ParseTupleAndKeywords (PyObject * argv , PyObject * kwds , const char * format , char * * kwdnames , ...) {
379
382
CallWithPolyglotArgs (int result , kwdnames , 4 , _PyTruffleArg_ParseTupleAndKeywords , argv , kwds , format , kwdnames );
380
383
return result ;
@@ -394,24 +397,27 @@ MUST_INLINE PyObject* PyTruffle_Stack2Tuple(PyObject** args, Py_ssize_t nargs) {
394
397
return argv ;
395
398
}
396
399
397
- int PyArg_ParseStack (PyObject * * args , Py_ssize_t nargs , PyObject * kwds , struct _PyArg_Parser * parser , ...) {
398
- CallWithPolyglotArgs (int result , parser , 4 , _PyTruffleArg_ParseTupleAndKeywords , PyTruffle_Stack2Tuple (args , nargs ), kwds , parser -> format , parser -> keywords );
400
+ int PyArg_ParseStack (PyObject * * args , Py_ssize_t nargs , const char * format , ...) {
401
+ // TODO(fa) Converting the stack to a tuple is rather slow. We should refactor
402
+ // '_PyTruffleArg_ParseTupleAndKeywords' (like CPython) into smaller operations.
403
+ CallWithPolyglotArgs (int result , parser , 3 , _PyTruffleArg_ParseTupleAndKeywords , PyTruffle_Stack2Tuple (args , nargs ), PyDict_New (), format , NULL );
399
404
return result ;
400
405
}
401
406
402
- int _PyArg_ParseStack_SizeT (PyObject * * args , Py_ssize_t nargs , PyObject * kwds , struct _PyArg_Parser * parser , ...) {
403
- CallWithPolyglotArgs (int result , parser , 4 , _PyTruffleArg_ParseTupleAndKeywords , PyTruffle_Stack2Tuple (args , nargs ), kwds , parser -> format , parser -> keywords );
407
+ int _PyArg_ParseStack_SizeT (PyObject * * args , Py_ssize_t nargs , const char * format , ...) {
408
+ // TODO(fa) Avoid usage of 'PyTruffle_Stack2Tuple'; see 'PyArg_ParseStack'.
409
+ CallWithPolyglotArgs (int result , parser , 3 , _PyTruffleArg_ParseTupleAndKeywords , PyTruffle_Stack2Tuple (args , nargs ), PyDict_New (), format , NULL );
404
410
return result ;
405
411
}
406
412
407
413
int _PyArg_ParseStackAndKeywords (PyObject * const * args , Py_ssize_t nargs , PyObject * kwnames , struct _PyArg_Parser * parser , ...) {
408
- // TODO(fa) That's not very fast and we should refactor these functions .
414
+ // TODO(fa) Avoid usage of 'PyTruffle_Stack2Tuple'; see 'PyArg_ParseStack' .
409
415
CallWithPolyglotArgs (int result , parser , 4 , _PyTruffleArg_ParseTupleAndKeywords , PyTruffle_Stack2Tuple (args , nargs ), kwnames , parser -> format , parser -> keywords );
410
416
return result ;
411
417
}
412
418
413
419
int _PyArg_ParseStackAndKeywords_SizeT (PyObject * const * args , Py_ssize_t nargs , PyObject * kwnames , struct _PyArg_Parser * parser , ...) {
414
- // TODO(fa) That's not very fast and we should refactor these functions .
420
+ // TODO(fa) Avoid usage of 'PyTruffle_Stack2Tuple'; see 'PyArg_ParseStack' .
415
421
CallWithPolyglotArgs (int result , parser , 4 , _PyTruffleArg_ParseTupleAndKeywords , PyTruffle_Stack2Tuple (args , nargs ), kwnames , parser -> format , parser -> keywords );
416
422
return result ;
417
423
}
0 commit comments