@@ -141,13 +141,16 @@ PyDoc_STRVAR(pysqlite_cursor_fetchmany__doc__,
141141"fetchmany($self, /, size=<unrepresentable>)\n"
142142"--\n"
143143"\n"
144- "Fetches several rows from the resultset." );
144+ "Fetches several rows from the resultset.\n"
145+ "\n"
146+ " size\n"
147+ " The number of rows to fetch. Defaults to the cursor\'s arraysize." );
145148
146149#define PYSQLITE_CURSOR_FETCHMANY_METHODDEF \
147150 {"fetchmany", (PyCFunction)(void(*)(void))pysqlite_cursor_fetchmany, METH_FASTCALL|METH_KEYWORDS, pysqlite_cursor_fetchmany__doc__},
148151
149152static PyObject *
150- pysqlite_cursor_fetchmany_impl (pysqlite_Cursor * self , int maxrows );
153+ pysqlite_cursor_fetchmany_impl (pysqlite_Cursor * self , PyObject * maxrows_obj );
151154
152155static PyObject *
153156pysqlite_cursor_fetchmany (pysqlite_Cursor * self , PyObject * const * args , Py_ssize_t nargs , PyObject * kwnames )
@@ -157,7 +160,7 @@ pysqlite_cursor_fetchmany(pysqlite_Cursor *self, PyObject *const *args, Py_ssize
157160 static _PyArg_Parser _parser = {NULL , _keywords , "fetchmany" , 0 };
158161 PyObject * argsbuf [1 ];
159162 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE (kwnames ) : 0 ) - 0 ;
160- int maxrows = self -> arraysize ;
163+ PyObject * maxrows_obj = NULL ;
161164
162165 args = _PyArg_UnpackKeywords (args , nargs , NULL , kwnames , & _parser , 0 , 1 , 0 , argsbuf );
163166 if (!args ) {
@@ -166,12 +169,9 @@ pysqlite_cursor_fetchmany(pysqlite_Cursor *self, PyObject *const *args, Py_ssize
166169 if (!noptargs ) {
167170 goto skip_optional_pos ;
168171 }
169- maxrows = _PyLong_AsInt (args [0 ]);
170- if (maxrows == -1 && PyErr_Occurred ()) {
171- goto exit ;
172- }
172+ maxrows_obj = args [0 ];
173173skip_optional_pos :
174- return_value = pysqlite_cursor_fetchmany_impl (self , maxrows );
174+ return_value = pysqlite_cursor_fetchmany_impl (self , maxrows_obj );
175175
176176exit :
177177 return return_value ;
@@ -256,4 +256,4 @@ pysqlite_cursor_close(pysqlite_Cursor *self, PyObject *Py_UNUSED(ignored))
256256{
257257 return pysqlite_cursor_close_impl (self );
258258}
259- /*[clinic end generated code: output=8b5ffd9029d33cd8 input=a9049054013a1b77]*/
259+ /*[clinic end generated code: output=53cab2e724cd2ba5 input=a9049054013a1b77]*/
0 commit comments