On Mon, 15 Oct 2007 at 07:36:30 -0600, Martin Michlmayr wrote:
> * Simon McVittie <[EMAIL PROTECTED]> [2007-10-15 11:30]:
> > A patch is attached. It makes the following changes to fix the FTBFS:

Um, oops. Patch *really* attached...
--- eunuchs-20050320.1.orig/debian/changelog
+++ eunuchs-20050320.1/debian/changelog
@@ -1,3 +1,11 @@
+eunuchs (20050320.1-0.2) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Port recvmsg.c, sendmsg.c to be compatible with Python 2.5 on 64-bit
+    platforms, as per PEP 353 (Closes: #424552).
+
+ -- Simon McVittie <[EMAIL PROTECTED]>  Sun, 14 Oct 2007 11:48:12 +0100
+
 eunuchs (20050320.1-0.1) unstable; urgency=low
 
   * Non-maintainer upload.
--- eunuchs-20050320.1.orig/lib/eunuchs/recvmsg.c
+++ eunuchs-20050320.1/lib/eunuchs/recvmsg.c
@@ -1,3 +1,7 @@
+/* PEP 353 support - declare that we will use use Py_ssize_t for the #
+ * specifier in PyArg_Parse etc. */
+#define PY_SSIZE_T_CLEAN
+
 #include <Python.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -5,13 +9,19 @@
 #include <arpa/inet.h>
 #include <assert.h>
 
+/* More PEP 353 support. In Python <= 2.4 sequences are indexed by int, in
+ * >= 2.5 they are indexed by Py_ssize_t (a signed version of size_t). */
+#ifndef PY_SSIZE_T_MAX
+typedef int Py_ssize_t;
+#endif
+
 #define CMSG_BUFSIZE 1000
 /* int recvmsg(int s, struct msghdr *msg, int flags); */
 static PyObject *my_recvmsg(PyObject *self, PyObject *args, PyObject *keywds) {
   int fd;
   int flags=0;
-  size_t maxsize=8192;
-  int ret;
+  int maxsize=8192;
+  Py_ssize_t ret;
   struct msghdr msg;
   struct sockaddr_in sa;
   struct iovec iov[1];
@@ -27,8 +37,13 @@
   msg.msg_name = &sa;
   msg.msg_namelen = sizeof(sa);
 
-  iov[0].iov_len = maxsize;
-  iov[0].iov_base = malloc(maxsize);
+  if (maxsize < 0) {
+    PyErr_SetString(PyExc_TypeError, "maxsize may not be negative");
+    return NULL;
+  }
+
+  iov[0].iov_len = (size_t) maxsize;
+  iov[0].iov_base = malloc(iov[0].iov_len);
   if (!iov[0].iov_base) {
     PyErr_SetFromErrno(PyExc_OSError);
     return NULL;
@@ -78,11 +93,13 @@
 			      spec_dst,
 			      addr);
       } else {
+        Py_ssize_t len = cur->cmsg_len - sizeof(struct cmsghdr);
+
 	entry = Py_BuildValue("(iis#)",
 			      cur->cmsg_level,
 			      cur->cmsg_type,
 			      CMSG_DATA(cur),
-			      cur->cmsg_len - sizeof(struct cmsghdr)
+			      len
 			      );
       }
       if (PyList_Append(ancillary, entry) < 0) {
--- eunuchs-20050320.1.orig/lib/eunuchs/sendmsg.c
+++ eunuchs-20050320.1/lib/eunuchs/sendmsg.c
@@ -1,3 +1,7 @@
+/* PEP 353 support - declare that we will use use Py_ssize_t for the #
+ * specifier in PyArg_Parse etc. */
+#define PY_SSIZE_T_CLEAN
+
 #include <Python.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -5,6 +9,12 @@
 #include <arpa/inet.h>
 #include <assert.h>
 
+/* More PEP 353 support. In Python <= 2.4 sequences are indexed by int, in
+ * >= 2.5 they are indexed by Py_ssize_t (a signed version of size_t). */
+#ifndef PY_SSIZE_T_MAX
+typedef int Py_ssize_t;
+#endif
+
 #define CMSG_BUFSIZE 1000
 /* int sendmsg(int s, struct msghdr *msg, int flags); */
 static PyObject *my_sendmsg(PyObject *self, PyObject *args, PyObject *keywds) {
@@ -13,6 +23,7 @@
   int ret;
   struct msghdr msg;
   struct sockaddr_in sa;
+  Py_ssize_t iov_len;
   struct iovec iov[1];
   char cmsgbuf[CMSG_BUFSIZE];
   PyObject *ancillary = NULL;
@@ -29,13 +40,15 @@
   if (!PyArg_ParseTupleAndKeywords(args, keywds, "it#si|iO", kwlist,
 				   &fd,
 				   &iov[0].iov_base,
-				   &iov[0].iov_len,
+				   &iov_len,
 				   &host,
 				   &port,
 				   &flags,
 				   &ancillary))
     return NULL;
 
+  iov[0].iov_len = iov_len;
+
   memset(&sa, 0, sizeof(sa));
   sa.sin_family = AF_INET;
   sa.sin_port = htons(port);
@@ -101,7 +114,7 @@
 	real_controllen += CMSG_SPACE(sizeof *info);
       } else {
 	char *data;
-	int len;
+	Py_ssize_t len;
 
 	if (PyString_AsStringAndSize(rest, &data, &len))
 	  return NULL; // TODO leaks

Attachment: signature.asc
Description: Digital signature

Reply via email to