mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 08:56:34 +03:00
Merge branch 'drop-py24' into devel
This commit is contained in:
commit
c63d623f65
1
NEWS
1
NEWS
|
@ -28,6 +28,7 @@ Bug fixes:
|
|||
Other changes:
|
||||
|
||||
- Added support for Python 3.3.
|
||||
- Dropped support for Python 2.4. Please use Psycopg 2.4.x if you need it.
|
||||
- `~psycopg2.errorcodes` map updated to PostgreSQL 9.2.
|
||||
- Dropped Zope adapter from source repository. ZPsycopgDA now has its own
|
||||
project at <http://github.com/psycopg/ZPsycopgDA>.
|
||||
|
|
|
@ -14,7 +14,7 @@ mature as the C implementation yet.
|
|||
|
||||
The current `!psycopg2` implementation supports:
|
||||
|
||||
- Python 2 versions from 2.4 to 2.7
|
||||
- Python 2 versions from 2.5 to 2.7
|
||||
- Python 3 versions from 3.1 to 3.3
|
||||
- PostgreSQL versions from 7.4 to 9.2
|
||||
|
||||
|
|
|
@ -41,23 +41,6 @@ Homepage: http://initd.org/projects/psycopg2
|
|||
# Import modules needed by _psycopg to allow tools like py2exe to do
|
||||
# their work without bothering about the module dependencies.
|
||||
|
||||
import sys, warnings
|
||||
if sys.version_info >= (2, 3):
|
||||
try:
|
||||
import datetime as _psycopg_needs_datetime
|
||||
except:
|
||||
warnings.warn(
|
||||
"can't import datetime module probably needed by _psycopg",
|
||||
RuntimeWarning)
|
||||
if sys.version_info >= (2, 4):
|
||||
try:
|
||||
import decimal as _psycopg_needs_decimal
|
||||
except:
|
||||
warnings.warn(
|
||||
"can't import decimal module probably needed by _psycopg",
|
||||
RuntimeWarning)
|
||||
del sys, warnings
|
||||
|
||||
# Note: the first internal import should be _psycopg, otherwise the real cause
|
||||
# of a failed loading of the C module may get hidden, see
|
||||
# http://archives.postgresql.org/psycopg/2011-02/msg00044.php
|
||||
|
|
|
@ -1351,7 +1351,7 @@ psyco_curs_copy_from(cursorObject *self, PyObject *args, PyObject *kwargs)
|
|||
PyObject *file, *columns = NULL, *res = NULL;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"O&s|ss" CONV_CODE_PY_SSIZE_T "O", kwlist,
|
||||
"O&s|ssnO", kwlist,
|
||||
_psyco_curs_has_read_check, &file, &table_name, &sep, &null, &bufsize,
|
||||
&columns))
|
||||
{
|
||||
|
@ -1524,7 +1524,7 @@ psyco_curs_copy_expert(cursorObject *self, PyObject *args, PyObject *kwargs)
|
|||
static char *kwlist[] = {"sql", "file", "size", NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"OO|" CONV_CODE_PY_SSIZE_T, kwlist, &sql, &file, &bufsize))
|
||||
"OO|n", kwlist, &sql, &file, &bufsize))
|
||||
{ return NULL; }
|
||||
|
||||
EXC_IF_CURS_CLOSED(self);
|
||||
|
|
|
@ -133,8 +133,6 @@ static struct PyGetSetDef error_getsets[] = {
|
|||
};
|
||||
|
||||
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
|
||||
/* Error.__reduce__
|
||||
*
|
||||
* The method is required to make exceptions picklable: set the cursor
|
||||
|
@ -229,21 +227,10 @@ error:
|
|||
return rv;
|
||||
}
|
||||
|
||||
#endif /* PY_VERSION_HEX >= 0x02050000 */
|
||||
|
||||
static PyMethodDef error_methods[] = {
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
/* Make Error and all its subclasses picklable.
|
||||
*
|
||||
* TODO: this comment applied to the __reduce_ex__ implementation: now
|
||||
* pickling may work on Py 2.4 too... but it's 2013 now.
|
||||
*
|
||||
* Don't do it it on Py 2.4: [__reduce_ex__] it is not used by the pickle
|
||||
* protocol, and if called manually fails in an unsettling way,
|
||||
* probably because the exceptions were old-style classes. */
|
||||
/* Make Error and all its subclasses picklable. */
|
||||
{"__reduce__", (PyCFunction)psyco_error_reduce, METH_NOARGS },
|
||||
{"__setstate__", (PyCFunction)psyco_error_setstate, METH_O },
|
||||
#endif
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ psyco_lobj_read(lobjectObject *self, PyObject *args)
|
|||
Py_ssize_t size = -1;
|
||||
char *buffer;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|" CONV_CODE_PY_SSIZE_T, &size)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "|n", &size)) return NULL;
|
||||
|
||||
EXC_IF_LOBJ_CLOSED(self);
|
||||
EXC_IF_LOBJ_LEVEL0(self);
|
||||
|
|
|
@ -31,36 +31,12 @@
|
|||
#include <stringobject.h>
|
||||
#endif
|
||||
|
||||
#if PY_VERSION_HEX < 0x02040000
|
||||
# error "psycopg requires Python >= 2.4"
|
||||
#endif
|
||||
|
||||
#if PY_VERSION_HEX < 0x02050000
|
||||
/* Function missing in Py 2.4 */
|
||||
#define PyErr_WarnEx(cat,msg,lvl) PyErr_Warn(cat,msg)
|
||||
#endif
|
||||
|
||||
#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
|
||||
typedef int Py_ssize_t;
|
||||
#define PY_SSIZE_T_MIN INT_MIN
|
||||
#define PY_SSIZE_T_MAX INT_MAX
|
||||
#define PY_FORMAT_SIZE_T ""
|
||||
#define PyInt_FromSsize_t(x) PyInt_FromLong((x))
|
||||
|
||||
#define lenfunc inquiry
|
||||
#define ssizeargfunc intargfunc
|
||||
#define readbufferproc getreadbufferproc
|
||||
#define writebufferproc getwritebufferproc
|
||||
#define segcountproc getsegcountproc
|
||||
#define charbufferproc getcharbufferproc
|
||||
|
||||
#define CONV_CODE_PY_SSIZE_T "i"
|
||||
#else
|
||||
#define CONV_CODE_PY_SSIZE_T "n"
|
||||
# error "psycopg requires Python >= 2.5"
|
||||
#endif
|
||||
|
||||
/* hash() return size changed around version 3.2a4 on 64bit platforms. Before
|
||||
* this, the return size was always a long, regardless of arch. ~3.2
|
||||
* this, the return size was always a long, regardless of arch. ~3.2
|
||||
* introduced the Py_hash_t & Py_uhash_t typedefs with the resulting sizes
|
||||
* based upon arch. */
|
||||
#if PY_VERSION_HEX < 0x030200A4
|
||||
|
@ -76,11 +52,6 @@ typedef unsigned long Py_uhash_t;
|
|||
#define PyVarObject_HEAD_INIT(x,n) PyObject_HEAD_INIT(x) n,
|
||||
#endif
|
||||
|
||||
/* Missing at least in Python 2.4 */
|
||||
#ifndef Py_MEMCPY
|
||||
#define Py_MEMCPY memcpy
|
||||
#endif
|
||||
|
||||
/* FORMAT_CODE_PY_SSIZE_T is for Py_ssize_t: */
|
||||
#define FORMAT_CODE_PY_SSIZE_T "%" PY_FORMAT_SIZE_T "d"
|
||||
|
||||
|
|
|
@ -22,10 +22,7 @@
|
|||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
# License for more details.
|
||||
|
||||
try:
|
||||
import decimal
|
||||
except:
|
||||
pass
|
||||
import decimal
|
||||
|
||||
import sys
|
||||
from functools import wraps
|
||||
|
@ -66,10 +63,6 @@ class TypesBasicTests(unittest.TestCase):
|
|||
self.failUnless(s == 1971, "wrong integer quoting: " + str(s))
|
||||
s = self.execute("SELECT %s AS foo", (1971L,))
|
||||
self.failUnless(s == 1971L, "wrong integer quoting: " + str(s))
|
||||
if sys.version_info[0:2] < (2, 4):
|
||||
s = self.execute("SELECT %s AS foo", (19.10,))
|
||||
self.failUnless(abs(s - 19.10) < 0.001,
|
||||
"wrong float quoting: " + str(s))
|
||||
|
||||
def testBoolean(self):
|
||||
x = self.execute("SELECT %s as foo", (False,))
|
||||
|
@ -78,21 +71,18 @@ class TypesBasicTests(unittest.TestCase):
|
|||
self.assert_(x is True)
|
||||
|
||||
def testDecimal(self):
|
||||
if sys.version_info[0:2] >= (2, 4):
|
||||
s = self.execute("SELECT %s AS foo", (decimal.Decimal("19.10"),))
|
||||
self.failUnless(s - decimal.Decimal("19.10") == 0,
|
||||
"wrong decimal quoting: " + str(s))
|
||||
s = self.execute("SELECT %s AS foo", (decimal.Decimal("NaN"),))
|
||||
self.failUnless(str(s) == "NaN", "wrong decimal quoting: " + str(s))
|
||||
self.failUnless(type(s) == decimal.Decimal, "wrong decimal conversion: " + repr(s))
|
||||
s = self.execute("SELECT %s AS foo", (decimal.Decimal("infinity"),))
|
||||
self.failUnless(str(s) == "NaN", "wrong decimal quoting: " + str(s))
|
||||
self.failUnless(type(s) == decimal.Decimal, "wrong decimal conversion: " + repr(s))
|
||||
s = self.execute("SELECT %s AS foo", (decimal.Decimal("-infinity"),))
|
||||
self.failUnless(str(s) == "NaN", "wrong decimal quoting: " + str(s))
|
||||
self.failUnless(type(s) == decimal.Decimal, "wrong decimal conversion: " + repr(s))
|
||||
else:
|
||||
return self.skipTest("decimal not available")
|
||||
s = self.execute("SELECT %s AS foo", (decimal.Decimal("19.10"),))
|
||||
self.failUnless(s - decimal.Decimal("19.10") == 0,
|
||||
"wrong decimal quoting: " + str(s))
|
||||
s = self.execute("SELECT %s AS foo", (decimal.Decimal("NaN"),))
|
||||
self.failUnless(str(s) == "NaN", "wrong decimal quoting: " + str(s))
|
||||
self.failUnless(type(s) == decimal.Decimal, "wrong decimal conversion: " + repr(s))
|
||||
s = self.execute("SELECT %s AS foo", (decimal.Decimal("infinity"),))
|
||||
self.failUnless(str(s) == "NaN", "wrong decimal quoting: " + str(s))
|
||||
self.failUnless(type(s) == decimal.Decimal, "wrong decimal conversion: " + repr(s))
|
||||
s = self.execute("SELECT %s AS foo", (decimal.Decimal("-infinity"),))
|
||||
self.failUnless(str(s) == "NaN", "wrong decimal quoting: " + str(s))
|
||||
self.failUnless(type(s) == decimal.Decimal, "wrong decimal conversion: " + repr(s))
|
||||
|
||||
def testFloatNan(self):
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue
Block a user