Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cpython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenVMS
Python
cpython
Commits
d8ee526115b4
Commit
d8ee526115b4
authored
4 years ago
by
Erlend Egeberg Aasland
Browse files
Options
Downloads
Patches
Plain Diff
bpo-40956: Convert _sqlite3.Row to Argument Clinic (GH-23964)
parent
1210b677cc94
Loading
Loading
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Modules/_sqlite/clinic/row.c.h
+56
-0
56 additions, 0 deletions
Modules/_sqlite/clinic/row.c.h
Modules/_sqlite/row.c
+30
-21
30 additions, 21 deletions
Modules/_sqlite/row.c
with
86 additions
and
21 deletions
Modules/_sqlite/clinic/row.c.h
0 → 100644
+
56
−
0
View file @
d8ee5261
/*[clinic input]
preserve
[clinic start generated code]*/
static
PyObject
*
pysqlite_row_new_impl
(
PyTypeObject
*
type
,
pysqlite_Cursor
*
cursor
,
PyObject
*
data
);
static
PyObject
*
pysqlite_row_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
PyObject
*
return_value
=
NULL
;
pysqlite_Cursor
*
cursor
;
PyObject
*
data
;
if
((
type
==
pysqlite_RowType
)
&&
!
_PyArg_NoKeywords
(
"Row"
,
kwargs
))
{
goto
exit
;
}
if
(
!
_PyArg_CheckPositional
(
"Row"
,
PyTuple_GET_SIZE
(
args
),
2
,
2
))
{
goto
exit
;
}
if
(
!
PyObject_TypeCheck
(
PyTuple_GET_ITEM
(
args
,
0
),
pysqlite_CursorType
))
{
_PyArg_BadArgument
(
"Row"
,
"argument 1"
,
(
pysqlite_CursorType
)
->
tp_name
,
PyTuple_GET_ITEM
(
args
,
0
));
goto
exit
;
}
cursor
=
(
pysqlite_Cursor
*
)
PyTuple_GET_ITEM
(
args
,
0
);
if
(
!
PyTuple_Check
(
PyTuple_GET_ITEM
(
args
,
1
)))
{
_PyArg_BadArgument
(
"Row"
,
"argument 2"
,
"tuple"
,
PyTuple_GET_ITEM
(
args
,
1
));
goto
exit
;
}
data
=
PyTuple_GET_ITEM
(
args
,
1
);
return_value
=
pysqlite_row_new_impl
(
type
,
cursor
,
data
);
exit:
return
return_value
;
}
PyDoc_STRVAR
(
pysqlite_row_keys__doc__
,
"keys($self, /)
\n
"
"--
\n
"
"
\n
"
"Returns the keys of the row."
);
#define PYSQLITE_ROW_KEYS_METHODDEF \
{"keys", (PyCFunction)pysqlite_row_keys, METH_NOARGS, pysqlite_row_keys__doc__},
static
PyObject
*
pysqlite_row_keys_impl
(
pysqlite_Row
*
self
);
static
PyObject
*
pysqlite_row_keys
(
pysqlite_Row
*
self
,
PyObject
*
Py_UNUSED
(
ignored
))
{
return
pysqlite_row_keys_impl
(
self
);
}
/*[clinic end generated code: output=8d29220b9cde035d input=a9049054013a1b77]*/
This diff is collapsed.
Click to expand it.
Modules/_sqlite/row.c
+
30
−
21
View file @
d8ee5261
...
...
@@ -23,6 +23,13 @@
#include
"row.h"
#include
"cursor.h"
#include
"clinic/row.c.h"
/*[clinic input]
module _sqlite3
class _sqlite3.Row "pysqlite_Row *" "pysqlite_RowType"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=384227da65f250fd]*/
void
pysqlite_row_dealloc
(
pysqlite_Row
*
self
)
{
...
...
@@ -35,4 +42,14 @@
Py_DECREF
(
tp
);
}
/*[clinic input]
@classmethod
_sqlite3.Row.__new__ as pysqlite_row_new
cursor: object(type='pysqlite_Cursor *', subclass_of='pysqlite_CursorType')
data: object(subclass_of='&PyTuple_Type')
/
[clinic start generated code]*/
static
PyObject
*
...
...
@@ -38,4 +55,6 @@
static
PyObject
*
pysqlite_row_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwargs
)
pysqlite_row_new_impl
(
PyTypeObject
*
type
,
pysqlite_Cursor
*
cursor
,
PyObject
*
data
)
/*[clinic end generated code: output=10d58b09a819a4c1 input=f6cd7e6e0935828d]*/
{
pysqlite_Row
*
self
;
...
...
@@ -40,7 +59,5 @@
{
pysqlite_Row
*
self
;
PyObject
*
data
;
pysqlite_Cursor
*
cursor
;
assert
(
type
!=
NULL
&&
type
->
tp_alloc
!=
NULL
);
...
...
@@ -44,21 +61,6 @@
assert
(
type
!=
NULL
&&
type
->
tp_alloc
!=
NULL
);
if
(
!
_PyArg_NoKeywords
(
"Row"
,
kwargs
))
return
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
"OO"
,
&
cursor
,
&
data
))
return
NULL
;
if
(
!
PyObject_TypeCheck
((
PyObject
*
)
cursor
,
pysqlite_CursorType
))
{
PyErr_SetString
(
PyExc_TypeError
,
"instance of cursor required for first argument"
);
return
NULL
;
}
if
(
!
PyTuple_Check
(
data
))
{
PyErr_SetString
(
PyExc_TypeError
,
"tuple required for second argument"
);
return
NULL
;
}
self
=
(
pysqlite_Row
*
)
type
->
tp_alloc
(
type
,
0
);
if
(
self
==
NULL
)
return
NULL
;
...
...
@@ -153,7 +155,15 @@
return
PyTuple_GET_SIZE
(
self
->
data
);
}
PyObject
*
pysqlite_row_keys
(
pysqlite_Row
*
self
,
PyObject
*
Py_UNUSED
(
ignored
))
/*[clinic input]
_sqlite3.Row.keys as pysqlite_row_keys
Returns the keys of the row.
[clinic start generated code]*/
static
PyObject
*
pysqlite_row_keys_impl
(
pysqlite_Row
*
self
)
/*[clinic end generated code: output=efe3dfb3af6edc07 input=7549a122827c5563]*/
{
PyObject
*
list
;
Py_ssize_t
nitems
,
i
;
...
...
@@ -204,8 +214,7 @@
}
static
PyMethodDef
row_methods
[]
=
{
{
"keys"
,
(
PyCFunction
)
pysqlite_row_keys
,
METH_NOARGS
,
PyDoc_STR
(
"Returns the keys of the row."
)},
PYSQLITE_ROW_KEYS_METHODDEF
{
NULL
,
NULL
}
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment