@@ -40,6 +40,11 @@ class frame "PyFrameObject *" "&PyFrame_Type"
4040[clinic start generated code]*/
4141/*[clinic end generated code: output=da39a3ee5e6b4b0d input=2d1dbf2e06cf351f]*/
4242
43+ /*[clinic input]
44+ class FrameLocalsProxy "PyFrameLocalsProxyObject *" "&PyFrameLocalsProxy_Type"
45+ [clinic start generated code]*/
46+ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=b877b1c7551e6925]*/
47+
4348
4449// Returns new reference or NULL
4550static PyObject *
@@ -452,36 +457,32 @@ framelocalsproxy_dealloc(PyObject *self)
452457 Py_TYPE (self )-> tp_free (self );
453458}
454459
460+ /*[clinic input]
461+ @vectorcall
462+ @classmethod
463+ FrameLocalsProxy.__new__ as framelocalsproxy_new
464+ frame: object
465+ /
466+
467+ Create a write-through view of the locals dictionary for a frame.
468+
469+ frame
470+ the frame object to wrap.
471+ [clinic start generated code]*/
472+
455473static PyObject *
456- framelocalsproxy_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
474+ framelocalsproxy_new_impl (PyTypeObject * type , PyObject * frame )
475+ /*[clinic end generated code: output=803b377132a928b9 input=5ab4ffd26ec8e290]*/
457476{
458- if (PyTuple_GET_SIZE (args ) != 1 ) {
459- PyErr_Format (PyExc_TypeError ,
460- "FrameLocalsProxy expected 1 argument, got %zd" ,
461- PyTuple_GET_SIZE (args ));
462- return NULL ;
463- }
464- PyObject * item = PyTuple_GET_ITEM (args , 0 );
465-
466- if (!PyFrame_Check (item )) {
467- PyErr_Format (PyExc_TypeError , "expect frame, not %T" , item );
477+ if (!PyFrame_Check (frame )) {
478+ PyErr_Format (PyExc_TypeError , "expect frame, not %T" , frame );
468479 return NULL ;
469480 }
470- PyFrameObject * frame = (PyFrameObject * )item ;
471-
472- if (kwds != NULL && PyDict_Size (kwds ) != 0 ) {
473- PyErr_SetString (PyExc_TypeError ,
474- "FrameLocalsProxy takes no keyword arguments" );
475- return 0 ;
476- }
477-
478481 PyFrameLocalsProxyObject * self = (PyFrameLocalsProxyObject * )type -> tp_alloc (type , 0 );
479482 if (self == NULL ) {
480483 return NULL ;
481484 }
482-
483- ((PyFrameLocalsProxyObject * )self )-> frame = (PyFrameObject * )Py_NewRef (frame );
484-
485+ self -> frame = (PyFrameObject * )Py_NewRef (frame );
485486 return (PyObject * )self ;
486487}
487488
@@ -988,15 +989,6 @@ static PyMethodDef framelocalsproxy_methods[] = {
988989 {NULL , NULL } /* sentinel */
989990};
990991
991- PyDoc_STRVAR (framelocalsproxy_doc ,
992- "FrameLocalsProxy($frame)\n"
993- "--\n"
994- "\n"
995- "Create a write-through view of the locals dictionary for a frame.\n"
996- "\n"
997- " frame\n"
998- " the frame object to wrap." );
999-
1000992PyTypeObject PyFrameLocalsProxy_Type = {
1001993 PyVarObject_HEAD_INIT (& PyType_Type , 0 )
1002994 .tp_name = "FrameLocalsProxy" ,
@@ -1017,20 +1009,14 @@ PyTypeObject PyFrameLocalsProxy_Type = {
10171009 .tp_alloc = PyType_GenericAlloc ,
10181010 .tp_new = framelocalsproxy_new ,
10191011 .tp_free = PyObject_GC_Del ,
1020- .tp_doc = framelocalsproxy_doc ,
1012+ .tp_doc = framelocalsproxy_new__doc__ ,
1013+ .tp_vectorcall = framelocalsproxy_vectorcall ,
10211014};
10221015
10231016PyObject *
10241017_PyFrameLocalsProxy_New (PyFrameObject * frame )
10251018{
1026- PyObject * args = PyTuple_Pack (1 , frame );
1027- if (args == NULL ) {
1028- return NULL ;
1029- }
1030-
1031- PyObject * proxy = framelocalsproxy_new (& PyFrameLocalsProxy_Type , args , NULL );
1032- Py_DECREF (args );
1033- return proxy ;
1019+ return framelocalsproxy_new_impl (& PyFrameLocalsProxy_Type , (PyObject * )frame );
10341020}
10351021
10361022static PyMemberDef frame_memberlist [] = {
0 commit comments