Skip to content

Commit b6873ee

Browse files
committed
Dropped support for Python 2.4
1 parent e65392e commit b6873ee

File tree

8 files changed

+21
-89
lines changed

8 files changed

+21
-89
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Bug fixes:
2828
Other changes:
2929

3030
- Added support for Python 3.3.
31+
- Dropped support for Python 2.4. Please use Psycopg 2.4.x if you need it.
3132
- `~psycopg2.errorcodes` map updated to PostgreSQL 9.2.
3233
- Dropped Zope adapter from source repository. ZPsycopgDA now has its own
3334
project at <http://github.com/psycopg/ZPsycopgDA>.

doc/src/install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mature as the C implementation yet.
1414

1515
The current `!psycopg2` implementation supports:
1616

17-
- Python 2 versions from 2.4 to 2.7
17+
- Python 2 versions from 2.5 to 2.7
1818
- Python 3 versions from 3.1 to 3.3
1919
- PostgreSQL versions from 7.4 to 9.2
2020

lib/__init__.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,6 @@
4141
# Import modules needed by _psycopg to allow tools like py2exe to do
4242
# their work without bothering about the module dependencies.
4343

44-
import sys, warnings
45-
if sys.version_info >= (2, 3):
46-
try:
47-
import datetime as _psycopg_needs_datetime
48-
except:
49-
warnings.warn(
50-
"can't import datetime module probably needed by _psycopg",
51-
RuntimeWarning)
52-
if sys.version_info >= (2, 4):
53-
try:
54-
import decimal as _psycopg_needs_decimal
55-
except:
56-
warnings.warn(
57-
"can't import decimal module probably needed by _psycopg",
58-
RuntimeWarning)
59-
del sys, warnings
60-
6144
# Note: the first internal import should be _psycopg, otherwise the real cause
6245
# of a failed loading of the C module may get hidden, see
6346
# http://archives.postgresql.org/psycopg/2011-02/msg00044.php

psycopg/cursor_type.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ psyco_curs_copy_from(cursorObject *self, PyObject *args, PyObject *kwargs)
13581358
PyObject *file, *columns = NULL, *res = NULL;
13591359

13601360
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
1361-
"O&s|ss" CONV_CODE_PY_SSIZE_T "O", kwlist,
1361+
"O&s|ssnO", kwlist,
13621362
_psyco_curs_has_read_check, &file, &table_name, &sep, &null, &bufsize,
13631363
&columns))
13641364
{
@@ -1535,7 +1535,7 @@ psyco_curs_copy_expert(cursorObject *self, PyObject *args, PyObject *kwargs)
15351535
static char *kwlist[] = {"sql", "file", "size", NULL};
15361536

15371537
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
1538-
"OO|" CONV_CODE_PY_SSIZE_T, kwlist, &sql, &file, &bufsize))
1538+
"OO|n", kwlist, &sql, &file, &bufsize))
15391539
{ return NULL; }
15401540

15411541
EXC_IF_CURS_CLOSED(self);

psycopg/error_type.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ static struct PyGetSetDef error_getsets[] = {
131131
};
132132

133133

134-
#if PY_VERSION_HEX >= 0x02050000
135-
136134
/* Error.__reduce__
137135
*
138136
* The method is required to make exceptions picklable: set the cursor
@@ -227,21 +225,10 @@ psyco_error_setstate(errorObject *self, PyObject *state)
227225
return rv;
228226
}
229227

230-
#endif /* PY_VERSION_HEX >= 0x02050000 */
231-
232228
static PyMethodDef error_methods[] = {
233-
#if PY_VERSION_HEX >= 0x02050000
234-
/* Make Error and all its subclasses picklable.
235-
*
236-
* TODO: this comment applied to the __reduce_ex__ implementation: now
237-
* pickling may work on Py 2.4 too... but it's 2013 now.
238-
*
239-
* Don't do it it on Py 2.4: [__reduce_ex__] it is not used by the pickle
240-
* protocol, and if called manually fails in an unsettling way,
241-
* probably because the exceptions were old-style classes. */
229+
/* Make Error and all its subclasses picklable. */
242230
{"__reduce__", (PyCFunction)psyco_error_reduce, METH_NOARGS },
243231
{"__setstate__", (PyCFunction)psyco_error_setstate, METH_O },
244-
#endif
245232
{NULL}
246233
};
247234

psycopg/lobject_type.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ psyco_lobj_read(lobjectObject *self, PyObject *args)
128128
Py_ssize_t size = -1;
129129
char *buffer;
130130

131-
if (!PyArg_ParseTuple(args, "|" CONV_CODE_PY_SSIZE_T, &size)) return NULL;
131+
if (!PyArg_ParseTuple(args, "|n", &size)) return NULL;
132132

133133
EXC_IF_LOBJ_CLOSED(self);
134134
EXC_IF_LOBJ_LEVEL0(self);

psycopg/python.h

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,36 +31,12 @@
3131
#include <stringobject.h>
3232
#endif
3333

34-
#if PY_VERSION_HEX < 0x02040000
35-
# error "psycopg requires Python >= 2.4"
36-
#endif
37-
3834
#if PY_VERSION_HEX < 0x02050000
39-
/* Function missing in Py 2.4 */
40-
#define PyErr_WarnEx(cat,msg,lvl) PyErr_Warn(cat,msg)
41-
#endif
42-
43-
#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
44-
typedef int Py_ssize_t;
45-
#define PY_SSIZE_T_MIN INT_MIN
46-
#define PY_SSIZE_T_MAX INT_MAX
47-
#define PY_FORMAT_SIZE_T ""
48-
#define PyInt_FromSsize_t(x) PyInt_FromLong((x))
49-
50-
#define lenfunc inquiry
51-
#define ssizeargfunc intargfunc
52-
#define readbufferproc getreadbufferproc
53-
#define writebufferproc getwritebufferproc
54-
#define segcountproc getsegcountproc
55-
#define charbufferproc getcharbufferproc
56-
57-
#define CONV_CODE_PY_SSIZE_T "i"
58-
#else
59-
#define CONV_CODE_PY_SSIZE_T "n"
35+
# error "psycopg requires Python >= 2.5"
6036
#endif
6137

6238
/* hash() return size changed around version 3.2a4 on 64bit platforms. Before
63-
* this, the return size was always a long, regardless of arch. ~3.2
39+
* this, the return size was always a long, regardless of arch. ~3.2
6440
* introduced the Py_hash_t & Py_uhash_t typedefs with the resulting sizes
6541
* based upon arch. */
6642
#if PY_VERSION_HEX < 0x030200A4
@@ -76,11 +52,6 @@ typedef unsigned long Py_uhash_t;
7652
#define PyVarObject_HEAD_INIT(x,n) PyObject_HEAD_INIT(x) n,
7753
#endif
7854

79-
/* Missing at least in Python 2.4 */
80-
#ifndef Py_MEMCPY
81-
#define Py_MEMCPY memcpy
82-
#endif
83-
8455
/* FORMAT_CODE_PY_SSIZE_T is for Py_ssize_t: */
8556
#define FORMAT_CODE_PY_SSIZE_T "%" PY_FORMAT_SIZE_T "d"
8657

tests/test_types_basic.py

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@
2222
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
2323
# License for more details.
2424

25-
try:
26-
import decimal
27-
except:
28-
pass
25+
import decimal
2926

3027
import sys
3128
from functools import wraps
@@ -66,10 +63,6 @@ def testNumber(self):
6663
self.failUnless(s == 1971, "wrong integer quoting: " + str(s))
6764
s = self.execute("SELECT %s AS foo", (1971L,))
6865
self.failUnless(s == 1971L, "wrong integer quoting: " + str(s))
69-
if sys.version_info[0:2] < (2, 4):
70-
s = self.execute("SELECT %s AS foo", (19.10,))
71-
self.failUnless(abs(s - 19.10) < 0.001,
72-
"wrong float quoting: " + str(s))
7366

7467
def testBoolean(self):
7568
x = self.execute("SELECT %s as foo", (False,))
@@ -78,21 +71,18 @@ def testBoolean(self):
7871
self.assert_(x is True)
7972

8073
def testDecimal(self):
81-
if sys.version_info[0:2] >= (2, 4):
82-
s = self.execute("SELECT %s AS foo", (decimal.Decimal("19.10"),))
83-
self.failUnless(s - decimal.Decimal("19.10") == 0,
84-
"wrong decimal quoting: " + str(s))
85-
s = self.execute("SELECT %s AS foo", (decimal.Decimal("NaN"),))
86-
self.failUnless(str(s) == "NaN", "wrong decimal quoting: " + str(s))
87-
self.failUnless(type(s) == decimal.Decimal, "wrong decimal conversion: " + repr(s))
88-
s = self.execute("SELECT %s AS foo", (decimal.Decimal("infinity"),))
89-
self.failUnless(str(s) == "NaN", "wrong decimal quoting: " + str(s))
90-
self.failUnless(type(s) == decimal.Decimal, "wrong decimal conversion: " + repr(s))
91-
s = self.execute("SELECT %s AS foo", (decimal.Decimal("-infinity"),))
92-
self.failUnless(str(s) == "NaN", "wrong decimal quoting: " + str(s))
93-
self.failUnless(type(s) == decimal.Decimal, "wrong decimal conversion: " + repr(s))
94-
else:
95-
return self.skipTest("decimal not available")
74+
s = self.execute("SELECT %s AS foo", (decimal.Decimal("19.10"),))
75+
self.failUnless(s - decimal.Decimal("19.10") == 0,
76+
"wrong decimal quoting: " + str(s))
77+
s = self.execute("SELECT %s AS foo", (decimal.Decimal("NaN"),))
78+
self.failUnless(str(s) == "NaN", "wrong decimal quoting: " + str(s))
79+
self.failUnless(type(s) == decimal.Decimal, "wrong decimal conversion: " + repr(s))
80+
s = self.execute("SELECT %s AS foo", (decimal.Decimal("infinity"),))
81+
self.failUnless(str(s) == "NaN", "wrong decimal quoting: " + str(s))
82+
self.failUnless(type(s) == decimal.Decimal, "wrong decimal conversion: " + repr(s))
83+
s = self.execute("SELECT %s AS foo", (decimal.Decimal("-infinity"),))
84+
self.failUnless(str(s) == "NaN", "wrong decimal quoting: " + str(s))
85+
self.failUnless(type(s) == decimal.Decimal, "wrong decimal conversion: " + repr(s))
9686

9787
def testFloatNan(self):
9888
try:

0 commit comments

Comments
 (0)