7c1d49e356
Move content from stx-gplv3 into stx-integ Packages will be relocated to stx-integ: base/ anaconda crontabs dnsmasq rsync database/ python-psycopg2 filesystem/ parted grub/ grub2 security/ python-keyring Change-Id: Ib5664fc4b8820590d77e32909674461209ceb699 Story: 2002801 Task: 22687 Signed-off-by: Scott Little <scott.little@windriver.com>
97 lines
3.2 KiB
Diff
97 lines
3.2 KiB
Diff
From 04fe7ce2bed4b20ffa89d12551bd2865d21caec1 Mon Sep 17 00:00:00 2001
|
|
From: Al Bailey <al.bailey@windriver.com>
|
|
Date: Tue, 29 Nov 2016 14:52:47 -0500
|
|
Subject: [PATCH 1/1] Manually patch 170,173,187 and 187 fix
|
|
|
|
---
|
|
psycopg/connection_int.c | 7 ++++++-
|
|
psycopg/error_type.c | 12 ++++++++++--
|
|
psycopg/lobject_type.c | 15 +++++++++------
|
|
3 files changed, 25 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c
|
|
index 7851b0a..5069e64 100644
|
|
--- a/psycopg/connection_int.c
|
|
+++ b/psycopg/connection_int.c
|
|
@@ -642,6 +642,7 @@ static int
|
|
_conn_poll_connecting(connectionObject *self)
|
|
{
|
|
int res = PSYCO_POLL_ERROR;
|
|
+ const char *msg;
|
|
|
|
Dprintf("conn_poll: poll connecting");
|
|
switch (PQconnectPoll(self->pgconn)) {
|
|
@@ -656,7 +657,11 @@ _conn_poll_connecting(connectionObject *self)
|
|
break;
|
|
case PGRES_POLLING_FAILED:
|
|
case PGRES_POLLING_ACTIVE:
|
|
- PyErr_SetString(OperationalError, "asynchronous connection failed");
|
|
+ msg = PQerrorMessage(self->pgconn);
|
|
+ if (!(msg && *msg)) {
|
|
+ msg = "asynchronous connection failed";
|
|
+ }
|
|
+ PyErr_SetString(OperationalError, msg);
|
|
res = PSYCO_POLL_ERROR;
|
|
break;
|
|
}
|
|
diff --git a/psycopg/error_type.c b/psycopg/error_type.c
|
|
index 106b87a..75761e8 100644
|
|
--- a/psycopg/error_type.c
|
|
+++ b/psycopg/error_type.c
|
|
@@ -163,8 +163,16 @@ psyco_error_reduce(errorObject *self)
|
|
if (2 != PyTuple_GET_SIZE(tuple)) { goto exit; }
|
|
|
|
if (!(dict = PyDict_New())) { goto error; }
|
|
- if (0 != PyDict_SetItemString(dict, "pgerror", self->pgerror)) { goto error; }
|
|
- if (0 != PyDict_SetItemString(dict, "pgcode", self->pgcode)) { goto error; }
|
|
+ if (self->pgerror) {
|
|
+ if (0 != PyDict_SetItemString(dict, "pgerror", self->pgerror)) {
|
|
+ goto error;
|
|
+ }
|
|
+ }
|
|
+ if (self->pgcode) {
|
|
+ if (0 != PyDict_SetItemString(dict, "pgcode", self->pgcode)) {
|
|
+ goto error;
|
|
+ }
|
|
+ }
|
|
|
|
{
|
|
PyObject *newtuple;
|
|
diff --git a/psycopg/lobject_type.c b/psycopg/lobject_type.c
|
|
index fee11c4..823a1b7 100644
|
|
--- a/psycopg/lobject_type.c
|
|
+++ b/psycopg/lobject_type.c
|
|
@@ -355,9 +355,11 @@ lobject_dealloc(PyObject* obj)
|
|
{
|
|
lobjectObject *self = (lobjectObject *)obj;
|
|
|
|
- if (lobject_close(self) < 0)
|
|
- PyErr_Print();
|
|
- Py_XDECREF((PyObject*)self->conn);
|
|
+ if (self->conn) { /* if not, init failed */
|
|
+ if (lobject_close(self) < 0)
|
|
+ PyErr_Print();
|
|
+ Py_XDECREF((PyObject*)self->conn);
|
|
+ }
|
|
PyMem_Free(self->smode);
|
|
|
|
Dprintf("lobject_dealloc: deleted lobject object at %p, refcnt = "
|
|
@@ -372,10 +374,11 @@ lobject_init(PyObject *obj, PyObject *args, PyObject *kwds)
|
|
int oid = (int)InvalidOid, new_oid = (int)InvalidOid;
|
|
const char *smode = "";
|
|
const char *new_file = NULL;
|
|
- PyObject *conn;
|
|
+ PyObject *conn = NULL;
|
|
|
|
- if (!PyArg_ParseTuple(args, "O|iziz",
|
|
- &conn, &oid, &smode, &new_oid, &new_file))
|
|
+ if (!PyArg_ParseTuple(args, "O!|iziz",
|
|
+ &connectionType, &conn,
|
|
+ &oid, &smode, &new_oid, &new_file))
|
|
return -1;
|
|
|
|
return lobject_setup((lobjectObject *)obj,
|
|
--
|
|
1.8.3.1
|
|
|