mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 09:24:07 +03:00
Encoding fixes.
This commit is contained in:
parent
f43a52f781
commit
b074dd4d8b
|
@ -1,5 +1,9 @@
|
|||
2007-01-16 Federico Di Gregorio <fog@initd.org>
|
||||
|
||||
* psycopg/connection_type.c: .set_client_encoding() now converts the
|
||||
argument to upper case to make sure it has the same case of the entries
|
||||
in the PostgreSQL -> Python encoding conversion table.
|
||||
|
||||
* lib/extras.py: merged DictCursor from #143 and renamed it RealDictCursor
|
||||
because allows access by cursor keys _only_. Also cleaned up a little bit
|
||||
the implementation of both DictCursor and RealDictCursor by introducing
|
||||
|
|
|
@ -100,10 +100,12 @@ qstring_quote(qstringObject *self)
|
|||
|
||||
/* TODO: we need a real translation table from postgres encoding names to
|
||||
python ones here */
|
||||
|
||||
|
||||
Dprintf("qstring_quote: encoding to %s", self->encoding);
|
||||
|
||||
if (PyUnicode_Check(self->wrapped) && self->encoding) {
|
||||
PyObject *enc = PyDict_GetItemString(psycoEncodings, self->encoding);
|
||||
/* note that pgenc is a borrowed reference */
|
||||
/* note that enc is a borrowed reference */
|
||||
|
||||
if (enc) {
|
||||
char *s = PyString_AsString(enc);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <stringobject.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define PSYCOPG_MODULE
|
||||
#include "psycopg/config.h"
|
||||
|
@ -179,12 +180,16 @@ psyco_conn_set_isolation_level(connectionObject *self, PyObject *args)
|
|||
static PyObject *
|
||||
psyco_conn_set_client_encoding(connectionObject *self, PyObject *args)
|
||||
{
|
||||
char *enc = NULL;
|
||||
char *pos, *enc = NULL;
|
||||
|
||||
EXC_IF_CONN_CLOSED(self);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s", &enc)) return NULL;
|
||||
|
||||
|
||||
/* convert to upper case */
|
||||
for (pos = enc ; *pos != '\0' ; pos++)
|
||||
*pos = toupper(*pos);
|
||||
|
||||
if (conn_set_client_encoding(self, enc) == 0) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
|
@ -272,7 +277,6 @@ static struct PyMemberDef connectionObject_members[] = {
|
|||
static int
|
||||
connection_setup(connectionObject *self, char *dsn)
|
||||
{
|
||||
int i;
|
||||
char *pos;
|
||||
|
||||
Dprintf("connection_setup: init connection object at %p, refcnt = %d",
|
||||
|
|
Loading…
Reference in New Issue
Block a user