mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-24 18:03:43 +03:00
Merge branch 'patch-328' into maint_2_6
This commit is contained in:
commit
6d2bd882ad
|
@ -60,8 +60,8 @@ RAISES_NEG HIDDEN int lobject_export(lobjectObject *self, const char *filename);
|
||||||
RAISES_NEG HIDDEN Py_ssize_t lobject_read(lobjectObject *self, char *buf, size_t len);
|
RAISES_NEG HIDDEN Py_ssize_t lobject_read(lobjectObject *self, char *buf, size_t len);
|
||||||
RAISES_NEG HIDDEN Py_ssize_t lobject_write(lobjectObject *self, const char *buf,
|
RAISES_NEG HIDDEN Py_ssize_t lobject_write(lobjectObject *self, const char *buf,
|
||||||
size_t len);
|
size_t len);
|
||||||
RAISES_NEG HIDDEN long lobject_seek(lobjectObject *self, long pos, int whence);
|
RAISES_NEG HIDDEN Py_ssize_t lobject_seek(lobjectObject *self, Py_ssize_t pos, int whence);
|
||||||
RAISES_NEG HIDDEN long lobject_tell(lobjectObject *self);
|
RAISES_NEG HIDDEN Py_ssize_t lobject_tell(lobjectObject *self);
|
||||||
RAISES_NEG HIDDEN int lobject_truncate(lobjectObject *self, size_t len);
|
RAISES_NEG HIDDEN int lobject_truncate(lobjectObject *self, size_t len);
|
||||||
RAISES_NEG HIDDEN int lobject_close(lobjectObject *self);
|
RAISES_NEG HIDDEN int lobject_close(lobjectObject *self);
|
||||||
|
|
||||||
|
|
|
@ -376,12 +376,12 @@ lobject_read(lobjectObject *self, char *buf, size_t len)
|
||||||
|
|
||||||
/* lobject_seek - move the current position in the lo */
|
/* lobject_seek - move the current position in the lo */
|
||||||
|
|
||||||
RAISES_NEG long
|
RAISES_NEG Py_ssize_t
|
||||||
lobject_seek(lobjectObject *self, long pos, int whence)
|
lobject_seek(lobjectObject *self, Py_ssize_t pos, int whence)
|
||||||
{
|
{
|
||||||
PGresult *pgres = NULL;
|
PGresult *pgres = NULL;
|
||||||
char *error = NULL;
|
char *error = NULL;
|
||||||
long where;
|
Py_ssize_t where;
|
||||||
|
|
||||||
Dprintf("lobject_seek: fd = %d, pos = %ld, whence = %d",
|
Dprintf("lobject_seek: fd = %d, pos = %ld, whence = %d",
|
||||||
self->fd, pos, whence);
|
self->fd, pos, whence);
|
||||||
|
@ -391,12 +391,12 @@ lobject_seek(lobjectObject *self, long pos, int whence)
|
||||||
|
|
||||||
#ifdef HAVE_LO64
|
#ifdef HAVE_LO64
|
||||||
if (self->conn->server_version < 90300) {
|
if (self->conn->server_version < 90300) {
|
||||||
where = (long)lo_lseek(self->conn->pgconn, self->fd, (int)pos, whence);
|
where = (Py_ssize_t)lo_lseek(self->conn->pgconn, self->fd, (int)pos, whence);
|
||||||
} else {
|
} else {
|
||||||
where = lo_lseek64(self->conn->pgconn, self->fd, pos, whence);
|
where = (Py_ssize_t)lo_lseek64(self->conn->pgconn, self->fd, pos, whence);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
where = (long)lo_lseek(self->conn->pgconn, self->fd, (int)pos, whence);
|
where = (Py_ssize_t)lo_lseek(self->conn->pgconn, self->fd, (int)pos, whence);
|
||||||
#endif
|
#endif
|
||||||
Dprintf("lobject_seek: where = %ld", where);
|
Dprintf("lobject_seek: where = %ld", where);
|
||||||
if (where < 0)
|
if (where < 0)
|
||||||
|
@ -412,12 +412,12 @@ lobject_seek(lobjectObject *self, long pos, int whence)
|
||||||
|
|
||||||
/* lobject_tell - tell the current position in the lo */
|
/* lobject_tell - tell the current position in the lo */
|
||||||
|
|
||||||
RAISES_NEG long
|
RAISES_NEG Py_ssize_t
|
||||||
lobject_tell(lobjectObject *self)
|
lobject_tell(lobjectObject *self)
|
||||||
{
|
{
|
||||||
PGresult *pgres = NULL;
|
PGresult *pgres = NULL;
|
||||||
char *error = NULL;
|
char *error = NULL;
|
||||||
long where;
|
Py_ssize_t where;
|
||||||
|
|
||||||
Dprintf("lobject_tell: fd = %d", self->fd);
|
Dprintf("lobject_tell: fd = %d", self->fd);
|
||||||
|
|
||||||
|
@ -426,12 +426,12 @@ lobject_tell(lobjectObject *self)
|
||||||
|
|
||||||
#ifdef HAVE_LO64
|
#ifdef HAVE_LO64
|
||||||
if (self->conn->server_version < 90300) {
|
if (self->conn->server_version < 90300) {
|
||||||
where = (long)lo_tell(self->conn->pgconn, self->fd);
|
where = (Py_ssize_t)lo_tell(self->conn->pgconn, self->fd);
|
||||||
} else {
|
} else {
|
||||||
where = lo_tell64(self->conn->pgconn, self->fd);
|
where = (Py_ssize_t)lo_tell64(self->conn->pgconn, self->fd);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
where = (long)lo_tell(self->conn->pgconn, self->fd);
|
where = (Py_ssize_t)lo_tell(self->conn->pgconn, self->fd);
|
||||||
#endif
|
#endif
|
||||||
Dprintf("lobject_tell: where = %ld", where);
|
Dprintf("lobject_tell: where = %ld", where);
|
||||||
if (where < 0)
|
if (where < 0)
|
||||||
|
|
|
@ -105,7 +105,7 @@ psyco_lobj_write(lobjectObject *self, PyObject *args)
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = PyInt_FromLong((long)res);
|
rv = PyInt_FromSsize_t((Py_ssize_t)res);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
Py_XDECREF(data);
|
Py_XDECREF(data);
|
||||||
|
@ -121,7 +121,7 @@ static PyObject *
|
||||||
psyco_lobj_read(lobjectObject *self, PyObject *args)
|
psyco_lobj_read(lobjectObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *res;
|
PyObject *res;
|
||||||
long where, end;
|
Py_ssize_t where, end;
|
||||||
Py_ssize_t size = -1;
|
Py_ssize_t size = -1;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
|
||||||
|
@ -165,10 +165,10 @@ psyco_lobj_read(lobjectObject *self, PyObject *args)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
psyco_lobj_seek(lobjectObject *self, PyObject *args)
|
psyco_lobj_seek(lobjectObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long offset, pos=0;
|
Py_ssize_t offset, pos=0;
|
||||||
int whence=0;
|
int whence=0;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l|i", &offset, &whence))
|
if (!PyArg_ParseTuple(args, "n|i", &offset, &whence))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
EXC_IF_LOBJ_CLOSED(self);
|
EXC_IF_LOBJ_CLOSED(self);
|
||||||
|
@ -187,8 +187,8 @@ psyco_lobj_seek(lobjectObject *self, PyObject *args)
|
||||||
#else
|
#else
|
||||||
if (offset < INT_MIN || offset > INT_MAX) {
|
if (offset < INT_MIN || offset > INT_MAX) {
|
||||||
PyErr_Format(InterfaceError,
|
PyErr_Format(InterfaceError,
|
||||||
"offset out of range (%ld): this psycopg version was not built "
|
"offset out of range (" FORMAT_CODE_PY_SSIZE_T "): "
|
||||||
"with lobject 64 API support",
|
"this psycopg version was not built with lobject 64 API support",
|
||||||
offset);
|
offset);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ psyco_lobj_seek(lobjectObject *self, PyObject *args)
|
||||||
if ((pos = lobject_seek(self, offset, whence)) < 0)
|
if ((pos = lobject_seek(self, offset, whence)) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyLong_FromLong(pos);
|
return PyLong_FromSsize_t(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* tell method - tell current position in the lobject */
|
/* tell method - tell current position in the lobject */
|
||||||
|
@ -208,7 +208,7 @@ psyco_lobj_seek(lobjectObject *self, PyObject *args)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
psyco_lobj_tell(lobjectObject *self, PyObject *args)
|
psyco_lobj_tell(lobjectObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long pos;
|
Py_ssize_t pos;
|
||||||
|
|
||||||
EXC_IF_LOBJ_CLOSED(self);
|
EXC_IF_LOBJ_CLOSED(self);
|
||||||
EXC_IF_LOBJ_LEVEL0(self);
|
EXC_IF_LOBJ_LEVEL0(self);
|
||||||
|
@ -217,7 +217,7 @@ psyco_lobj_tell(lobjectObject *self, PyObject *args)
|
||||||
if ((pos = lobject_tell(self)) < 0)
|
if ((pos = lobject_tell(self)) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return PyLong_FromLong(pos);
|
return PyLong_FromSsize_t(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* unlink method - unlink (destroy) the lobject */
|
/* unlink method - unlink (destroy) the lobject */
|
||||||
|
@ -274,9 +274,9 @@ psyco_lobj_get_closed(lobjectObject *self, void *closure)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
psyco_lobj_truncate(lobjectObject *self, PyObject *args)
|
psyco_lobj_truncate(lobjectObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
long len = 0;
|
Py_ssize_t len = 0;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "|l", &len))
|
if (!PyArg_ParseTuple(args, "|n", &len))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
EXC_IF_LOBJ_CLOSED(self);
|
EXC_IF_LOBJ_CLOSED(self);
|
||||||
|
@ -286,16 +286,16 @@ psyco_lobj_truncate(lobjectObject *self, PyObject *args)
|
||||||
#ifdef HAVE_LO64
|
#ifdef HAVE_LO64
|
||||||
if (len > INT_MAX && self->conn->server_version < 90300) {
|
if (len > INT_MAX && self->conn->server_version < 90300) {
|
||||||
PyErr_Format(NotSupportedError,
|
PyErr_Format(NotSupportedError,
|
||||||
"len out of range (%ld): server version %d "
|
"len out of range (" FORMAT_CODE_PY_SSIZE_T "): "
|
||||||
"does not support the lobject 64 API",
|
"server version %d does not support the lobject 64 API",
|
||||||
len, self->conn->server_version);
|
len, self->conn->server_version);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (len > INT_MAX) {
|
if (len > INT_MAX) {
|
||||||
PyErr_Format(InterfaceError,
|
PyErr_Format(InterfaceError,
|
||||||
"len out of range (%ld): this psycopg version was not built "
|
"len out of range (" FORMAT_CODE_PY_SSIZE_T "): "
|
||||||
"with lobject 64 API support",
|
"this psycopg version was not built with lobject 64 API support",
|
||||||
len);
|
len);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user