Skip to content

Commit b8ace97

Browse files
author
gerhard.haering
committed
Fixes issue #3103. In the sqlite3 module, made one more function static. All renaming public symbos now have the pysqlite prefix to avoid name clashes. This at least once created problems where the same symbol name appeared somewhere in Apache and the sqlite3 module was used from mod_python.
git-svn-id: http://svn.python.org/projects/python/trunk@66412 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 90932bb commit b8ace97

File tree

9 files changed

+31
-28
lines changed

9 files changed

+31
-28
lines changed

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ Extension Modules
148148

149149
- sqlite3: Changed docstring of iterdump() to mark method as "Non-standard".
150150

151+
- Issue #3103: Reduced globals symbols used by sqlite3 module and made sure all
152+
remaining ones have "pysqlite_" prefix.
153+
151154
Tests
152155
-----
153156

Modules/_sqlite/connection.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, PyObject* isolation_level);
3939

4040

41-
void _sqlite3_result_error(sqlite3_context* ctx, const char* errmsg, int len)
41+
static void _sqlite3_result_error(sqlite3_context* ctx, const char* errmsg, int len)
4242
{
4343
/* in older SQLite versions, calling sqlite3_result_error in callbacks
4444
* triggers a bug in SQLite that leads either to irritating results or
@@ -363,7 +363,7 @@ PyObject* _pysqlite_connection_begin(pysqlite_Connection* self)
363363
goto error;
364364
}
365365

366-
rc = _sqlite_step_with_busyhandler(statement, self);
366+
rc = pysqlite_step(statement, self);
367367
if (rc == SQLITE_DONE) {
368368
self->inTransaction = 1;
369369
} else {
@@ -406,7 +406,7 @@ PyObject* pysqlite_connection_commit(pysqlite_Connection* self, PyObject* args)
406406
goto error;
407407
}
408408

409-
rc = _sqlite_step_with_busyhandler(statement, self);
409+
rc = pysqlite_step(statement, self);
410410
if (rc == SQLITE_DONE) {
411411
self->inTransaction = 0;
412412
} else {
@@ -452,7 +452,7 @@ PyObject* pysqlite_connection_rollback(pysqlite_Connection* self, PyObject* args
452452
goto error;
453453
}
454454

455-
rc = _sqlite_step_with_busyhandler(statement, self);
455+
rc = pysqlite_step(statement, self);
456456
if (rc == SQLITE_DONE) {
457457
self->inTransaction = 0;
458458
} else {

Modules/_sqlite/cursor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
605605
/* Keep trying the SQL statement until the schema stops changing. */
606606
while (1) {
607607
/* Actually execute the SQL statement. */
608-
rc = _sqlite_step_with_busyhandler(self->statement->st, self->connection);
608+
rc = pysqlite_step(self->statement->st, self->connection);
609609
if (rc == SQLITE_DONE || rc == SQLITE_ROW) {
610610
/* If it worked, let's get out of the loop */
611611
break;
@@ -803,7 +803,7 @@ PyObject* pysqlite_cursor_executescript(pysqlite_Cursor* self, PyObject* args)
803803
/* execute statement, and ignore results of SELECT statements */
804804
rc = SQLITE_ROW;
805805
while (rc == SQLITE_ROW) {
806-
rc = _sqlite_step_with_busyhandler(statement, self->connection);
806+
rc = pysqlite_step(statement, self->connection);
807807
/* TODO: we probably need more error handling here */
808808
}
809809

@@ -871,7 +871,7 @@ PyObject* pysqlite_cursor_iternext(pysqlite_Cursor *self)
871871
}
872872

873873
if (self->statement) {
874-
rc = _sqlite_step_with_busyhandler(self->statement->st, self->connection);
874+
rc = pysqlite_step(self->statement->st, self->connection);
875875
if (rc != SQLITE_DONE && rc != SQLITE_ROW) {
876876
(void)pysqlite_statement_reset(self->statement);
877877
Py_DECREF(next_row);

Modules/_sqlite/microprotocols.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535

3636
PyObject *psyco_adapters;
3737

38-
/* microprotocols_init - initialize the adapters dictionary */
38+
/* pysqlite_microprotocols_init - initialize the adapters dictionary */
3939

4040
int
41-
microprotocols_init(PyObject *dict)
41+
pysqlite_microprotocols_init(PyObject *dict)
4242
{
4343
/* create adapters dictionary and put it in module namespace */
4444
if ((psyco_adapters = PyDict_New()) == NULL) {
@@ -49,10 +49,10 @@ microprotocols_init(PyObject *dict)
4949
}
5050

5151

52-
/* microprotocols_add - add a reverse type-caster to the dictionary */
52+
/* pysqlite_microprotocols_add - add a reverse type-caster to the dictionary */
5353

5454
int
55-
microprotocols_add(PyTypeObject *type, PyObject *proto, PyObject *cast)
55+
pysqlite_microprotocols_add(PyTypeObject *type, PyObject *proto, PyObject *cast)
5656
{
5757
PyObject* key;
5858
int rc;
@@ -70,10 +70,10 @@ microprotocols_add(PyTypeObject *type, PyObject *proto, PyObject *cast)
7070
return rc;
7171
}
7272

73-
/* microprotocols_adapt - adapt an object to the built-in protocol */
73+
/* pysqlite_microprotocols_adapt - adapt an object to the built-in protocol */
7474

7575
PyObject *
76-
microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt)
76+
pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt)
7777
{
7878
PyObject *adapter, *key;
7979

@@ -132,11 +132,11 @@ microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt)
132132
/** module-level functions **/
133133

134134
PyObject *
135-
psyco_microprotocols_adapt(pysqlite_Cursor *self, PyObject *args)
135+
pysqlite_adapt(pysqlite_Cursor *self, PyObject *args)
136136
{
137137
PyObject *obj, *alt = NULL;
138138
PyObject *proto = (PyObject*)&pysqlite_PrepareProtocolType;
139139

140140
if (!PyArg_ParseTuple(args, "O|OO", &obj, &proto, &alt)) return NULL;
141-
return microprotocols_adapt(obj, proto, alt);
141+
return pysqlite_microprotocols_adapt(obj, proto, alt);
142142
}

Modules/_sqlite/microprotocols.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ extern PyObject *psyco_adapters;
4141
/** exported functions **/
4242

4343
/* used by module.c to init the microprotocols system */
44-
extern int microprotocols_init(PyObject *dict);
45-
extern int microprotocols_add(
44+
extern int pysqlite_microprotocols_init(PyObject *dict);
45+
extern int pysqlite_microprotocols_add(
4646
PyTypeObject *type, PyObject *proto, PyObject *cast);
47-
extern PyObject *microprotocols_adapt(
47+
extern PyObject *pysqlite_microprotocols_adapt(
4848
PyObject *obj, PyObject *proto, PyObject *alt);
4949

5050
extern PyObject *
51-
psyco_microprotocols_adapt(pysqlite_Cursor* self, PyObject *args);
52-
#define psyco_microprotocols_adapt_doc \
51+
pysqlite_adapt(pysqlite_Cursor* self, PyObject *args);
52+
#define pysqlite_adapt_doc \
5353
"adapt(obj, protocol, alternate) -> adapt obj to given protocol. Non-standard."
5454

5555
#endif /* !defined(PSYCOPG_MICROPROTOCOLS_H) */

Modules/_sqlite/module.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static PyObject* module_register_adapter(PyObject* self, PyObject* args)
160160
pysqlite_BaseTypeAdapted = 1;
161161
}
162162

163-
rc = microprotocols_add(type, (PyObject*)&pysqlite_PrepareProtocolType, caster);
163+
rc = pysqlite_microprotocols_add(type, (PyObject*)&pysqlite_PrepareProtocolType, caster);
164164
if (rc == -1)
165165
return NULL;
166166

@@ -244,8 +244,8 @@ static PyMethodDef module_methods[] = {
244244
METH_VARARGS, module_register_adapter_doc},
245245
{"register_converter", (PyCFunction)module_register_converter,
246246
METH_VARARGS, module_register_converter_doc},
247-
{"adapt", (PyCFunction)psyco_microprotocols_adapt, METH_VARARGS,
248-
psyco_microprotocols_adapt_doc},
247+
{"adapt", (PyCFunction)pysqlite_adapt, METH_VARARGS,
248+
pysqlite_adapt_doc},
249249
{"enable_callback_tracebacks", (PyCFunction)enable_callback_tracebacks,
250250
METH_VARARGS, enable_callback_tracebacks_doc},
251251
{NULL, NULL}
@@ -423,7 +423,7 @@ PyMODINIT_FUNC init_sqlite3(void)
423423
Py_DECREF(tmp_obj);
424424

425425
/* initialize microprotocols layer */
426-
microprotocols_init(dict);
426+
pysqlite_microprotocols_init(dict);
427427

428428
/* initialize the default converters */
429429
converters_init(dict);

Modules/_sqlite/statement.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ void pysqlite_statement_bind_parameters(pysqlite_Statement* self, PyObject* para
250250
if (!_need_adapt(current_param)) {
251251
adapted = current_param;
252252
} else {
253-
adapted = microprotocols_adapt(current_param, (PyObject*)&pysqlite_PrepareProtocolType, NULL);
253+
adapted = pysqlite_microprotocols_adapt(current_param, (PyObject*)&pysqlite_PrepareProtocolType, NULL);
254254
if (adapted) {
255255
Py_DECREF(current_param);
256256
} else {
@@ -295,7 +295,7 @@ void pysqlite_statement_bind_parameters(pysqlite_Statement* self, PyObject* para
295295
if (!_need_adapt(current_param)) {
296296
adapted = current_param;
297297
} else {
298-
adapted = microprotocols_adapt(current_param, (PyObject*)&pysqlite_PrepareProtocolType, NULL);
298+
adapted = pysqlite_microprotocols_adapt(current_param, (PyObject*)&pysqlite_PrepareProtocolType, NULL);
299299
if (adapted) {
300300
Py_DECREF(current_param);
301301
} else {

Modules/_sqlite/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "module.h"
2525
#include "connection.h"
2626

27-
int _sqlite_step_with_busyhandler(sqlite3_stmt* statement, pysqlite_Connection* connection)
27+
int pysqlite_step(sqlite3_stmt* statement, pysqlite_Connection* connection)
2828
{
2929
int rc;
3030

Modules/_sqlite/util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "sqlite3.h"
2929
#include "connection.h"
3030

31-
int _sqlite_step_with_busyhandler(sqlite3_stmt* statement, pysqlite_Connection* connection);
31+
int pysqlite_step(sqlite3_stmt* statement, pysqlite_Connection* connection);
3232

3333
/**
3434
* Checks the SQLite error code and sets the appropriate DB-API exception.

0 commit comments

Comments
 (0)