Skip to content

Commit c63d623

Browse files
committed
Merge branch 'drop-py24' into devel
2 parents beea32e + b6873ee commit c63d623

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
@@ -1351,7 +1351,7 @@ psyco_curs_copy_from(cursorObject *self, PyObject *args, PyObject *kwargs)
13511351
PyObject *file, *columns = NULL, *res = NULL;
13521352

13531353
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
1354-
"O&s|ss" CONV_CODE_PY_SSIZE_T "O", kwlist,
1354+
"O&s|ssnO", kwlist,
13551355
_psyco_curs_has_read_check, &file, &table_name, &sep, &null, &bufsize,
13561356
&columns))
13571357
{
@@ -1524,7 +1524,7 @@ psyco_curs_copy_expert(cursorObject *self, PyObject *args, PyObject *kwargs)
15241524
static char *kwlist[] = {"sql", "file", "size", NULL};
15251525

15261526
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
1527-
"OO|" CONV_CODE_PY_SSIZE_T, kwlist, &sql, &file, &bufsize))
1527+
"OO|n", kwlist, &sql, &file, &bufsize))
15281528
{ return NULL; }
15291529

15301530
EXC_IF_CURS_CLOSED(self);

psycopg/error_type.c

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

135135

136-
#if PY_VERSION_HEX >= 0x02050000
137-
138136
/* Error.__reduce__
139137
*
140138
* The method is required to make exceptions picklable: set the cursor
@@ -229,21 +227,10 @@ psyco_error_setstate(errorObject *self, PyObject *state)
229227
return rv;
230228
}
231229

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

psycopg/lobject_type.c

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

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

132132
EXC_IF_LOBJ_CLOSED(self);
133133
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)