static PyObject * psyco_conn_set_client_encoding(connectionObject *self, PyObject *args) { const char *enc = NULL; char *buffer; size_t i, j; EXC_IF_CONN_CLOSED(self); if (!PyArg_ParseTuple(args, "s", &enc)) return NULL; /* convert to upper case and remove '-' and '_' from string */ buffer = PyMem_Malloc(strlen(enc)+1); for (i=j=0 ; i < strlen(enc) ; i++) { if (enc[i] == '_' || enc[i] == '-') continue; else buffer[j++] = toupper(enc[i]); } buffer[j] = '\0'; if (conn_set_client_encoding(self, buffer)) { PyMem_Free(buffer); return NULL; } else { PyMem_Free(buffer); Py_INCREF(Py_None); return Py_None; } }
static PyObject * psyco_conn_set_client_encoding(connectionObject *self, PyObject *args) { const char *enc; PyObject *rv = NULL; EXC_IF_CONN_CLOSED(self); EXC_IF_CONN_ASYNC(self, set_client_encoding); EXC_IF_TPC_PREPARED(self, set_client_encoding); if (!PyArg_ParseTuple(args, "s", &enc)) return NULL; if (conn_set_client_encoding(self, enc) >= 0) { Py_INCREF(Py_None); rv = Py_None; } return rv; }