Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e7d731fc
Commit
e7d731fc
authored
May 09, 2007
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use AsCharBuffer to get C strings out of Python strings.
parent
bdea48b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
30 deletions
+15
-30
Modules/_sqlite/cursor.c
Modules/_sqlite/cursor.c
+4
-13
Modules/_sqlite/statement.c
Modules/_sqlite/statement.c
+11
-17
No files found.
Modules/_sqlite/cursor.c
View file @
e7d731fc
...
...
@@ -409,8 +409,8 @@ PyObject* _pysqlite_fetch_one_row(pysqlite_Cursor* self)
PyObject
*
_pysqlite_query_execute
(
pysqlite_Cursor
*
self
,
int
multiple
,
PyObject
*
args
)
{
PyObject
*
operation
;
PyObject
*
operation_bytestr
=
NULL
;
char
*
operation_cstr
;
const
char
*
operation_cstr
;
Py_ssize_t
operation_len
;
PyObject
*
parameters_list
=
NULL
;
PyObject
*
parameters_iter
=
NULL
;
PyObject
*
parameters
=
NULL
;
...
...
@@ -495,16 +495,8 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
rc
=
pysqlite_statement_reset
(
self
->
statement
);
}
if
(
PyString_Check
(
operation
))
{
operation_cstr
=
PyString_AsString
(
operation
);
}
else
{
operation_bytestr
=
PyUnicode_AsUTF8String
(
operation
);
if
(
!
operation_bytestr
)
{
goto
error
;
}
operation_cstr
=
PyString_AsString
(
operation_bytestr
);
}
if
(
PyObject_AsCharBuffer
(
operation
,
&
operation_cstr
,
&
operation_len
)
<
0
)
goto
error
;
/* reset description and rowcount */
Py_DECREF
(
self
->
description
);
...
...
@@ -714,7 +706,6 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
}
error:
Py_XDECREF
(
operation_bytestr
);
Py_XDECREF
(
parameters
);
Py_XDECREF
(
parameters_iter
);
Py_XDECREF
(
parameters_list
);
...
...
Modules/_sqlite/statement.c
View file @
e7d731fc
...
...
@@ -44,30 +44,20 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con
{
const
char
*
tail
;
int
rc
;
PyObject
*
sql_
str
;
char
*
sql_cstr
;
const
char
*
sql_c
str
;
Py_ssize_t
sql_cstr_len
;
self
->
st
=
NULL
;
self
->
in_use
=
0
;
if
(
PyString_Check
(
sql
))
{
sql_str
=
sql
;
Py_INCREF
(
sql_str
);
}
else
if
(
PyUnicode_Check
(
sql
))
{
sql_str
=
PyUnicode_AsUTF8String
(
sql
);
if
(
!
sql_str
)
{
rc
=
PYSQLITE_SQL_WRONG_TYPE
;
return
rc
;
}
}
else
{
if
(
PyObject_AsCharBuffer
(
sql
,
&
sql_cstr
,
&
sql_cstr_len
)
<
0
)
{
rc
=
PYSQLITE_SQL_WRONG_TYPE
;
return
rc
;
}
self
->
in_weakreflist
=
NULL
;
self
->
sql
=
sql_str
;
sql_cstr
=
PyString_AsString
(
sql_str
);
Py_INCREF
(
sql
);
self
->
sql
=
sql
;
rc
=
sqlite3_prepare
(
connection
->
db
,
sql_cstr
,
...
...
@@ -219,10 +209,14 @@ int pysqlite_statement_recompile(pysqlite_Statement* self, PyObject* params)
{
const
char
*
tail
;
int
rc
;
char
*
sql_cstr
;
const
char
*
sql_cstr
;
Py_ssize_t
sql_len
;
sqlite3_stmt
*
new_st
;
sql_cstr
=
PyString_AsString
(
self
->
sql
);
if
(
PyObject_AsCharBuffer
(
self
->
sql
,
&
sql_cstr
,
&
sql_len
)
<
0
)
{
rc
=
PYSQLITE_SQL_WRONG_TYPE
;
return
rc
;
}
rc
=
sqlite3_prepare
(
self
->
db
,
sql_cstr
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment