Commit 5ed30dcd authored by Tres Seaver's avatar Tres Seaver

Made C extensions work for 64-bit Python 2.5.x / 2.6.x.

parent 09cea559
...@@ -56,6 +56,11 @@ Features Added ...@@ -56,6 +56,11 @@ Features Added
Bugs Fixed Bugs Fixed
++++++++++ ++++++++++
- Made C extensions work for 64-bit Python 2.5.x / 2.6.x.
- Unfutzed test failures due to use of naive timezones with ``datetime``
instances.
- LP #397861: exporting $PYTHON in generated 'zopectl' for fixing import issue - LP #397861: exporting $PYTHON in generated 'zopectl' for fixing import issue
with "bin/zopectl adduser" with "bin/zopectl adduser"
......
...@@ -54,6 +54,17 @@ ...@@ -54,6 +54,17 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
typedef int Py_ssize_t;
typedef Py_ssize_t (*lenfunc)(PyObject *);
typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t);
typedef PyObject *(*ssizessizeargfunc)(PyObject *, Py_ssize_t, Py_ssize_t);
typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *);
typedef int(*ssizessizeobjargproc)(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
#define PY_SSIZE_T_MAX INT_MAX
#define PY_SSIZE_T_MIN INT_MIN
#endif
static void static void
PyVar_Assign(PyObject **v, PyObject *e) PyVar_Assign(PyObject **v, PyObject *e)
...@@ -349,9 +360,9 @@ static void PermissionRole_dealloc(PermissionRole *self); ...@@ -349,9 +360,9 @@ static void PermissionRole_dealloc(PermissionRole *self);
static PyObject *PermissionRole_getattro(PermissionRole *self, PyObject *name); static PyObject *PermissionRole_getattro(PermissionRole *self, PyObject *name);
static PyObject *imPermissionRole_of(imPermissionRole *self, PyObject *parent); static PyObject *imPermissionRole_of(imPermissionRole *self, PyObject *parent);
static int imPermissionRole_length(imPermissionRole *self); static Py_ssize_t imPermissionRole_length(imPermissionRole *self);
static PyObject *imPermissionRole_get(imPermissionRole *self, static PyObject *imPermissionRole_get(imPermissionRole *self,
int item); Py_ssize_t item);
static void imPermissionRole_dealloc(imPermissionRole *self); static void imPermissionRole_dealloc(imPermissionRole *self);
static PyObject *rolesForPermissionOn(PyObject *self, PyObject *args); static PyObject *rolesForPermissionOn(PyObject *self, PyObject *args);
...@@ -593,16 +604,16 @@ static PyMethodDef imPermissionRole_methods[] = { ...@@ -593,16 +604,16 @@ static PyMethodDef imPermissionRole_methods[] = {
}; };
static PySequenceMethods imSequenceMethods = { static PySequenceMethods imSequenceMethods = {
(inquiry) imPermissionRole_length, /* sq_length */ (lenfunc) imPermissionRole_length, /* sq_length */
(binaryfunc) NULL, /* sq_concat */ (binaryfunc) NULL, /* sq_concat */
(intargfunc) NULL, /* sq_repeat */ (ssizeargfunc) NULL, /* sq_repeat */
(intargfunc) imPermissionRole_get, /* sq_item */ (ssizeargfunc) imPermissionRole_get, /* sq_item */
(intintargfunc) NULL, /* sq_slice */ (ssizessizeargfunc) NULL, /* sq_slice */
(intobjargproc) NULL, /* sq_ass_item */ (ssizeobjargproc) NULL, /* sq_ass_item */
(intintobjargproc) NULL, /* sq_ass_slice */ (ssizessizeobjargproc) NULL, /* sq_ass_slice */
(objobjproc) NULL, /* sq_contains */ (objobjproc) NULL, /* sq_contains */
(binaryfunc) NULL, /* sq_inplace_concat */ (binaryfunc) NULL, /* sq_inplace_concat */
(intargfunc) NULL /* sq_inplace_repeat */ (ssizeargfunc) NULL /* sq_inplace_repeat */
}; };
static PyExtensionClass imPermissionRoleType = { static PyExtensionClass imPermissionRoleType = {
...@@ -1613,9 +1624,9 @@ imPermissionRole_of(imPermissionRole *self, PyObject *value) { ...@@ -1613,9 +1624,9 @@ imPermissionRole_of(imPermissionRole *self, PyObject *value) {
/* /*
** imPermissionRole_length ** imPermissionRole_length
*/ */
static int imPermissionRole_length(imPermissionRole *self) { static Py_ssize_t imPermissionRole_length(imPermissionRole *self) {
int l; Py_ssize_t l;
PyObject *v; PyObject *v;
PyObject *pa; PyObject *pa;
...@@ -1654,7 +1665,7 @@ static int imPermissionRole_length(imPermissionRole *self) { ...@@ -1654,7 +1665,7 @@ static int imPermissionRole_length(imPermissionRole *self) {
*/ */
static PyObject *imPermissionRole_get(imPermissionRole *self, static PyObject *imPermissionRole_get(imPermissionRole *self,
int item) { Py_ssize_t item) {
PyObject *v; PyObject *v;
PyObject *pa; PyObject *pa;
......
...@@ -21,6 +21,17 @@ static char Record_module_documentation[] = ...@@ -21,6 +21,17 @@ static char Record_module_documentation[] =
/* ----------------------------------------------------- */ /* ----------------------------------------------------- */
#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
typedef int Py_ssize_t;
typedef Py_ssize_t (*lenfunc)(PyObject *);
typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t);
typedef PyObject *(*ssizessizeargfunc)(PyObject *, Py_ssize_t, Py_ssize_t);
typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *);
typedef int(*ssizessizeobjargproc)(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
#define PY_SSIZE_T_MAX INT_MAX
#define PY_SSIZE_T_MIN INT_MIN
#endif
static void PyVar_Assign(PyObject **v, PyObject *e) { Py_XDECREF(*v); *v=e;} static void PyVar_Assign(PyObject **v, PyObject *e) { Py_XDECREF(*v); *v=e;}
#define ASSIGN(V,E) PyVar_Assign(&(V),(E)) #define ASSIGN(V,E) PyVar_Assign(&(V),(E))
#define UNLESS(E) if(!(E)) #define UNLESS(E) if(!(E))
...@@ -41,10 +52,10 @@ staticforward PyExtensionClass RecordType; ...@@ -41,10 +52,10 @@ staticforward PyExtensionClass RecordType;
/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */
static int static Py_ssize_t
Record_init(Record *self) Record_init(Record *self)
{ {
int l; Py_ssize_t l;
UNLESS(self->schema) UNLESS(self->schema)
UNLESS(self->schema=PyObject_GetAttr(OBJECT(self->ob_type), UNLESS(self->schema=PyObject_GetAttr(OBJECT(self->ob_type),
...@@ -67,7 +78,7 @@ static PyObject * ...@@ -67,7 +78,7 @@ static PyObject *
Record___setstate__(Record *self, PyObject *args) Record___setstate__(Record *self, PyObject *args)
{ {
PyObject *state=0, *parent, **d; PyObject *state=0, *parent, **d;
int l, ls, i; Py_ssize_t l, ls, i;
if((l=Record_init(self)) < 0) return NULL; if((l=Record_init(self)) < 0) return NULL;
...@@ -102,7 +113,7 @@ static PyObject * ...@@ -102,7 +113,7 @@ static PyObject *
Record___getstate__( Record *self, PyObject *args) Record___getstate__( Record *self, PyObject *args)
{ {
PyObject *r, **d, *v; PyObject *r, **d, *v;
int i, l; Py_ssize_t i, l;
UNLESS(self->data) return PyTuple_New(0); UNLESS(self->data) return PyTuple_New(0);
...@@ -162,7 +173,7 @@ Record_dealloc(Record *self) ...@@ -162,7 +173,7 @@ Record_dealloc(Record *self)
static PyObject * static PyObject *
Record_getattr(Record *self, PyObject *name) Record_getattr(Record *self, PyObject *name)
{ {
int l, i; Py_ssize_t l, i;
PyObject *io; PyObject *io;
if((l=Record_init(self)) < 0) return NULL; if((l=Record_init(self)) < 0) return NULL;
...@@ -197,7 +208,7 @@ Record_getattr(Record *self, PyObject *name) ...@@ -197,7 +208,7 @@ Record_getattr(Record *self, PyObject *name)
static int static int
Record_setattr(Record *self, PyObject *name, PyObject *v) Record_setattr(Record *self, PyObject *name, PyObject *v)
{ {
int l, i; Py_ssize_t l, i;
PyObject *io; PyObject *io;
if((l=Record_init(self)) < 0) return -1; if((l=Record_init(self)) < 0) return -1;
...@@ -225,7 +236,8 @@ Record_setattr(Record *self, PyObject *name, PyObject *v) ...@@ -225,7 +236,8 @@ Record_setattr(Record *self, PyObject *name, PyObject *v)
static int static int
Record_compare(Record *v, Record *w) Record_compare(Record *v, Record *w)
{ {
int lv, lw, i, c; Py_ssize_t lv, lw, i;
int c;
PyObject **dv, **dw; PyObject **dv, **dw;
if((lv=Record_init(v)) < 0) return -1; if((lv=Record_init(v)) < 0) return -1;
...@@ -258,7 +270,7 @@ Record_concat(Record *self, PyObject *bb) ...@@ -258,7 +270,7 @@ Record_concat(Record *self, PyObject *bb)
} }
static PyObject * static PyObject *
Record_repeat(Record *self, int n) Record_repeat(Record *self, Py_ssize_t n)
{ {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"Record objects do not support repetition"); "Record objects do not support repetition");
...@@ -280,10 +292,10 @@ IndexError(int i) ...@@ -280,10 +292,10 @@ IndexError(int i)
} }
static PyObject * static PyObject *
Record_item(Record *self, int i) Record_item(Record *self, Py_ssize_t i)
{ {
PyObject *o; PyObject *o;
int l; Py_ssize_t l;
if((l=Record_init(self)) < 0) return NULL; if((l=Record_init(self)) < 0) return NULL;
if(i < 0 || i >= l) return IndexError(i); if(i < 0 || i >= l) return IndexError(i);
...@@ -296,7 +308,7 @@ Record_item(Record *self, int i) ...@@ -296,7 +308,7 @@ Record_item(Record *self, int i)
} }
static PyObject * static PyObject *
Record_slice(Record *self, int ilow, int ihigh) Record_slice(Record *self, Py_ssize_t ilow, Py_ssize_t ihigh)
{ {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"Record objects do not support slicing"); "Record objects do not support slicing");
...@@ -304,9 +316,9 @@ Record_slice(Record *self, int ilow, int ihigh) ...@@ -304,9 +316,9 @@ Record_slice(Record *self, int ilow, int ihigh)
} }
static int static int
Record_ass_item(Record *self, int i, PyObject *v) Record_ass_item(Record *self, Py_ssize_t i, PyObject *v)
{ {
int l; Py_ssize_t l;
if((l=Record_init(self)) < 0) return -1; if((l=Record_init(self)) < 0) return -1;
if(i < 0 || i >= l) if(i < 0 || i >= l)
...@@ -335,13 +347,13 @@ Record_ass_slice(Record *self, int ilow, int ihigh, PyObject *v) ...@@ -335,13 +347,13 @@ Record_ass_slice(Record *self, int ilow, int ihigh, PyObject *v)
} }
static PySequenceMethods Record_as_sequence = { static PySequenceMethods Record_as_sequence = {
(inquiry)Record_init, /*sq_length*/ (lenfunc)Record_init, /*sq_length*/
(binaryfunc)Record_concat, /*sq_concat*/ (binaryfunc)Record_concat, /*sq_concat*/
(intargfunc)Record_repeat, /*sq_repeat*/ (ssizeargfunc)Record_repeat, /*sq_repeat*/
(intargfunc)Record_item, /*sq_item*/ (ssizeargfunc)Record_item, /*sq_item*/
(intintargfunc)Record_slice, /*sq_slice*/ (ssizessizeargfunc)Record_slice, /*sq_slice*/
(intobjargproc)Record_ass_item, /*sq_ass_item*/ (ssizeobjargproc)Record_ass_item, /*sq_ass_item*/
(intintobjargproc)Record_ass_slice, /*sq_ass_slice*/ (ssizessizeobjargproc)Record_ass_slice, /*sq_ass_slice*/
}; };
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
...@@ -349,7 +361,7 @@ static PySequenceMethods Record_as_sequence = { ...@@ -349,7 +361,7 @@ static PySequenceMethods Record_as_sequence = {
static PyObject * static PyObject *
Record_subscript(Record *self, PyObject *key) Record_subscript(Record *self, PyObject *key)
{ {
int i, l; Py_ssize_t i, l;
PyObject *io; PyObject *io;
if((l=Record_init(self)) < 0) return NULL; if((l=Record_init(self)) < 0) return NULL;
...@@ -389,7 +401,7 @@ Record_subscript(Record *self, PyObject *key) ...@@ -389,7 +401,7 @@ Record_subscript(Record *self, PyObject *key)
static int static int
Record_ass_sub(Record *self, PyObject *key, PyObject *v) Record_ass_sub(Record *self, PyObject *key, PyObject *v)
{ {
int i, l; Py_ssize_t i, l;
PyObject *io; PyObject *io;
if((l=Record_init(self)) < 0) return -1; if((l=Record_init(self)) < 0) return -1;
...@@ -422,7 +434,7 @@ Record_ass_sub(Record *self, PyObject *key, PyObject *v) ...@@ -422,7 +434,7 @@ Record_ass_sub(Record *self, PyObject *key, PyObject *v)
} }
static PyMappingMethods Record_as_mapping = { static PyMappingMethods Record_as_mapping = {
(inquiry)Record_init, /*mp_length*/ (lenfunc)Record_init, /*mp_length*/
(binaryfunc)Record_subscript, /*mp_subscript*/ (binaryfunc)Record_subscript, /*mp_subscript*/
(objobjargproc)Record_ass_sub, /*mp_ass_subscript*/ (objobjargproc)Record_ass_sub, /*mp_ass_subscript*/
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment