Skip to content
Browse files

Merge branch 'drop-py24' into devel

  • Loading branch information...
2 parents beea32e + b6873ee commit c63d623f65bfee7b7370b130d0472deb9c86858e @dvarrazzo committed
Showing with 21 additions and 89 deletions.
  1. +1 −0 NEWS
  2. +1 −1 doc/src/install.rst
  3. +0 −17 lib/__init__.py
  4. +2 −2 psycopg/cursor_type.c
  5. +1 −14 psycopg/error_type.c
  6. +1 −1 psycopg/lobject_type.c
  7. +2 −31 psycopg/python.h
  8. +13 −23 tests/test_types_basic.py
View
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>.
View
2 doc/src/install.rst
@@ -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
View
17 lib/__init__.py
@@ -41,23 +41,6 @@
# 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
View
4 psycopg/cursor_type.c
@@ -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);
View
15 psycopg/error_type.c
@@ -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 @@ psyco_error_setstate(errorObject *self, PyObject *state)
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}
};
View
2 psycopg/lobject_type.c
@@ -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);
View
33 psycopg/python.h
@@ -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"
View
36 tests/test_types_basic.py
@@ -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 @@ def testNumber(self):
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 @@ def testBoolean(self):
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:

0 comments on commit c63d623

Please sign in to comment.
Something went wrong with that request. Please try again.