Skip to content

Commit 95ff64d

Browse files
committed
Dropped encoding attribute from list adapter
1 parent 6bc4b23 commit 95ff64d

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

psycopg/adapter_list.c

+5-15
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ list_prepare(listObject *self, PyObject *args)
103103
if (!PyArg_ParseTuple(args, "O!", &connectionType, &conn))
104104
return NULL;
105105

106-
/* note that we don't copy the encoding from the connection, but take a
107-
reference to it; we'll need it during the recursive adapt() call (the
108-
encoding is here for a future expansion that will make .getquoted()
109-
work even without a connection to the backend. */
110106
Py_CLEAR(self->connection);
111107
Py_INCREF(conn);
112108
self->connection = conn;
@@ -154,7 +150,7 @@ static PyMethodDef listObject_methods[] = {
154150
/* initialization and finalization methods */
155151

156152
static int
157-
list_setup(listObject *self, PyObject *obj, const char *enc)
153+
list_setup(listObject *self, PyObject *obj)
158154
{
159155
Dprintf("list_setup: init list object at %p, refcnt = "
160156
FORMAT_CODE_PY_SSIZE_T,
@@ -164,9 +160,6 @@ list_setup(listObject *self, PyObject *obj, const char *enc)
164160
if (!PyList_Check(obj))
165161
return -1;
166162

167-
/* FIXME: remove this orrible strdup */
168-
if (enc) self->encoding = strdup(enc);
169-
170163
self->connection = NULL;
171164
Py_INCREF(obj);
172165
self->wrapped = obj;
@@ -195,7 +188,6 @@ list_dealloc(PyObject* obj)
195188

196189
Py_CLEAR(self->wrapped);
197190
Py_CLEAR(self->connection);
198-
if (self->encoding) free(self->encoding);
199191

200192
Dprintf("list_dealloc: deleted list object at %p, "
201193
"refcnt = " FORMAT_CODE_PY_SSIZE_T, obj, Py_REFCNT(obj));
@@ -207,12 +199,11 @@ static int
207199
list_init(PyObject *obj, PyObject *args, PyObject *kwds)
208200
{
209201
PyObject *l;
210-
const char *enc = "latin-1"; /* default encoding as in Python */
211202

212-
if (!PyArg_ParseTuple(args, "O|s", &l, &enc))
203+
if (!PyArg_ParseTuple(args, "O", &l))
213204
return -1;
214205

215-
return list_setup((listObject *)obj, l, enc);
206+
return list_setup((listObject *)obj, l);
216207
}
217208

218209
static PyObject *
@@ -279,10 +270,9 @@ PyObject *
279270
psyco_List(PyObject *module, PyObject *args)
280271
{
281272
PyObject *str;
282-
const char *enc = "latin-1"; /* default encoding as in Python */
283273

284-
if (!PyArg_ParseTuple(args, "O|s", &str, &enc))
274+
if (!PyArg_ParseTuple(args, "O", &str))
285275
return NULL;
286276

287-
return PyObject_CallFunction((PyObject *)&listType, "Os", str, enc);
277+
return PyObject_CallFunctionObjArgs((PyObject *)&listType, "O", str, NULL);
288278
}

psycopg/adapter_list.h

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ typedef struct {
3737

3838
PyObject *wrapped;
3939
PyObject *connection;
40-
char *encoding;
4140
} listObject;
4241

4342
HIDDEN PyObject *psyco_List(PyObject *module, PyObject *args);

0 commit comments

Comments
 (0)