Skip to content

Commit b503db9

Browse files
committed
psycopg2.Error object and type renamed more consistently
1 parent 114c62f commit b503db9

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

psycopg/diagnostics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extern HIDDEN PyTypeObject diagnosticsType;
3333
typedef struct {
3434
PyObject_HEAD
3535

36-
PsycoErrorObject *err; /* exception to retrieve the diagnostics from */
36+
errorObject *err; /* exception to retrieve the diagnostics from */
3737

3838
} diagnosticsObject;
3939

psycopg/diagnostics_type.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,14 @@ diagnostics_init(diagnosticsObject *self, PyObject *args, PyObject *kwds)
122122
if (!PyArg_ParseTuple(args, "O", &err))
123123
return -1;
124124

125-
if (!PyObject_TypeCheck(err, &ErrorType)) {
125+
if (!PyObject_TypeCheck(err, &errorType)) {
126126
PyErr_SetString(PyExc_TypeError,
127127
"The argument must be a psycopg2.Error");
128128
return -1;
129129
}
130130

131131
Py_INCREF(err);
132-
self->err = (PsycoErrorObject *)err;
132+
self->err = (errorObject *)err;
133133
return 0;
134134
}
135135

psycopg/error.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#ifndef PSYCOPG_ERROR_H
2727
#define PSYCOPG_ERROR_H 1
2828

29-
extern HIDDEN PyTypeObject ErrorType;
29+
extern HIDDEN PyTypeObject errorType;
3030

3131
typedef struct {
3232
PyBaseExceptionObject exc;
@@ -36,8 +36,8 @@ typedef struct {
3636
cursorObject *cursor;
3737
char *codec;
3838
PGresult *pgres;
39-
} PsycoErrorObject;
39+
} errorObject;
4040

41-
HIDDEN PyObject *error_text_from_chars(PsycoErrorObject *self, const char *str);
41+
HIDDEN PyObject *error_text_from_chars(errorObject *self, const char *str);
4242

4343
#endif /* PSYCOPG_ERROR_H */

psycopg/error_type.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333

3434
PyObject *
35-
error_text_from_chars(PsycoErrorObject *self, const char *str)
35+
error_text_from_chars(errorObject *self, const char *str)
3636
{
3737
if (str == NULL) {
3838
Py_INCREF(Py_None);
@@ -61,11 +61,11 @@ static const char diag_doc[] =
6161
"A Diagnostics object to get further information about the error";
6262

6363
static PyMemberDef error_members[] = {
64-
{ "pgerror", T_OBJECT, offsetof(PsycoErrorObject, pgerror),
64+
{ "pgerror", T_OBJECT, offsetof(errorObject, pgerror),
6565
READONLY, (char *)pgerror_doc },
66-
{ "pgcode", T_OBJECT, offsetof(PsycoErrorObject, pgcode),
66+
{ "pgcode", T_OBJECT, offsetof(errorObject, pgcode),
6767
READONLY, (char *)pgcode_doc },
68-
{ "cursor", T_OBJECT, offsetof(PsycoErrorObject, cursor),
68+
{ "cursor", T_OBJECT, offsetof(errorObject, cursor),
6969
READONLY, (char *)cursor_doc },
7070
{ NULL }
7171
};
@@ -78,7 +78,7 @@ error_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
7878
}
7979

8080
static int
81-
error_init(PsycoErrorObject *self, PyObject *args, PyObject *kwargs)
81+
error_init(errorObject *self, PyObject *args, PyObject *kwargs)
8282
{
8383
if (((PyTypeObject *)PyExc_StandardError)->tp_init(
8484
(PyObject *)self, args, kwargs) < 0) {
@@ -88,15 +88,15 @@ error_init(PsycoErrorObject *self, PyObject *args, PyObject *kwargs)
8888
}
8989

9090
static int
91-
error_traverse(PsycoErrorObject *self, visitproc visit, void *arg)
91+
error_traverse(errorObject *self, visitproc visit, void *arg)
9292
{
9393
Py_VISIT(self->cursor);
9494
return ((PyTypeObject *)PyExc_StandardError)->tp_traverse(
9595
(PyObject *)self, visit, arg);
9696
}
9797

9898
static int
99-
error_clear(PsycoErrorObject *self)
99+
error_clear(errorObject *self)
100100
{
101101
Py_CLEAR(self->pgerror);
102102
Py_CLEAR(self->pgcode);
@@ -107,15 +107,15 @@ error_clear(PsycoErrorObject *self)
107107
}
108108

109109
static void
110-
error_dealloc(PsycoErrorObject *self)
110+
error_dealloc(errorObject *self)
111111
{
112112
error_clear(self);
113113
return Py_TYPE(self)->tp_free((PyObject *)self);
114114
}
115115

116116

117117
static PyObject *
118-
error_get_diag(PsycoErrorObject *self, void *closure)
118+
error_get_diag(errorObject *self, void *closure)
119119
{
120120
return PyObject_CallFunctionObjArgs(
121121
(PyObject *)&diagnosticsType, (PyObject *)self, NULL);
@@ -136,7 +136,7 @@ static struct PyGetSetDef error_getsets[] = {
136136
* would require implementing __getstate__, and as of 2012 it's a little
137137
* bit too late to care. */
138138
static PyObject *
139-
psyco_error_reduce(PsycoErrorObject *self)
139+
psyco_error_reduce(errorObject *self)
140140
{
141141
PyObject *meth = NULL;
142142
PyObject *tuple = NULL;
@@ -187,7 +187,7 @@ psyco_error_reduce(PsycoErrorObject *self)
187187
}
188188

189189
PyObject *
190-
psyco_error_setstate(PsycoErrorObject *self, PyObject *state)
190+
psyco_error_setstate(errorObject *self, PyObject *state)
191191
{
192192
PyObject *rv = NULL;
193193

@@ -242,10 +242,10 @@ static PyMethodDef error_methods[] = {
242242
};
243243

244244

245-
PyTypeObject ErrorType = {
245+
PyTypeObject errorType = {
246246
PyVarObject_HEAD_INIT(NULL, 0)
247247
"psycopg2.Error",
248-
sizeof(PsycoErrorObject),
248+
sizeof(errorObject),
249249
0,
250250
(destructor)error_dealloc, /* tp_dealloc */
251251
0, /*tp_print*/

psycopg/pqpath.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ pq_raise(connectionObject *conn, cursorObject *curs, PGresult **pgres)
218218

219219
pyerr = psyco_set_error(exc, curs, err2);
220220

221-
if (pyerr && PyObject_TypeCheck(pyerr, &ErrorType)) {
222-
PsycoErrorObject *perr = (PsycoErrorObject *)pyerr;
221+
if (pyerr && PyObject_TypeCheck(pyerr, &errorType)) {
222+
errorObject *perr = (errorObject *)pyerr;
223223

224224
PyMem_Free(perr->codec);
225225
psycopg_strdup(&perr->codec, conn->codec, 0);

psycopg/psycopgmodule.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ psyco_errors_init(void)
448448
int rv = -1;
449449

450450
/* 'Error' has been defined elsewhere: only init the other classes */
451-
Error = (PyObject *)&ErrorType;
451+
Error = (PyObject *)&errorType;
452452

453453
for (i = 1; exctable[i].name; i++) {
454454
if (!(dict = PyDict_New())) { goto exit; }
@@ -534,8 +534,8 @@ psyco_set_error(PyObject *exc, cursorObject *curs, const char *msg)
534534
return NULL;
535535
}
536536

537-
if (err && PyObject_TypeCheck(err, &ErrorType)) {
538-
PsycoErrorObject *perr = (PsycoErrorObject *)err;
537+
if (err && PyObject_TypeCheck(err, &errorType)) {
538+
errorObject *perr = (errorObject *)err;
539539
if (curs) {
540540
Py_CLEAR(perr->cursor);
541541
Py_INCREF(curs);
@@ -782,7 +782,7 @@ INIT_MODULE(_psycopg)(void)
782782
Py_TYPE(&chunkType) = &PyType_Type;
783783
Py_TYPE(&NotifyType) = &PyType_Type;
784784
Py_TYPE(&XidType) = &PyType_Type;
785-
Py_TYPE(&ErrorType) = &PyType_Type;
785+
Py_TYPE(&errorType) = &PyType_Type;
786786
Py_TYPE(&diagnosticsType) = &PyType_Type;
787787

788788
if (PyType_Ready(&connectionType) == -1) goto exit;
@@ -800,8 +800,8 @@ INIT_MODULE(_psycopg)(void)
800800
if (PyType_Ready(&chunkType) == -1) goto exit;
801801
if (PyType_Ready(&NotifyType) == -1) goto exit;
802802
if (PyType_Ready(&XidType) == -1) goto exit;
803-
ErrorType.tp_base = (PyTypeObject *)PyExc_StandardError;
804-
if (PyType_Ready(&ErrorType) == -1) goto exit;
803+
errorType.tp_base = (PyTypeObject *)PyExc_StandardError;
804+
if (PyType_Ready(&errorType) == -1) goto exit;
805805
if (PyType_Ready(&diagnosticsType) == -1) goto exit;
806806

807807
#ifdef PSYCOPG_EXTENSIONS
@@ -937,7 +937,7 @@ INIT_MODULE(_psycopg)(void)
937937
pydatetimeType.tp_alloc = PyType_GenericAlloc;
938938
NotifyType.tp_alloc = PyType_GenericAlloc;
939939
XidType.tp_alloc = PyType_GenericAlloc;
940-
ErrorType.tp_alloc = PyType_GenericAlloc;
940+
errorType.tp_alloc = PyType_GenericAlloc;
941941
diagnosticsType.tp_alloc = PyType_GenericAlloc;
942942

943943
#ifdef PSYCOPG_EXTENSIONS

0 commit comments

Comments
 (0)