diff Python/mactoolboxglue.c @ 40053:693ff5d73412 2.4

Port of universal binary support for Mac OSX from python 2.5. This takes away the need for the out-of-tree universal binary support that was used to build the 2.4.3 installer. Missing here relative to that tree are some changes to IDLE, IMHO those patches aren't appropriate for the 2.4 branch and users are better of using 2.5's IDLE.
author Ronald Oussoren <ronaldoussoren@mac.com>
date Sun, 08 Oct 2006 17:41:25 +0000
parents 7ed899b61182
children
line wrap: on
line diff
--- a/Python/mactoolboxglue.c	Sun Oct 08 14:24:26 2006 +0000
+++ b/Python/mactoolboxglue.c	Sun Oct 08 17:41:25 2006 +0000
@@ -25,7 +25,7 @@
 
 #include "Python.h"
 #include "pymactoolbox.h"
-
+#include <arpa/inet.h> /* for ntohl, htonl */
 
 /* Like strerror() but for Mac OS error numbers */
 char *
@@ -156,12 +156,14 @@
 int
 PyMac_GetOSType(PyObject *v, OSType *pr)
 {
+	int32_t tmp;
 	if (!PyString_Check(v) || PyString_Size(v) != 4) {
 		PyErr_SetString(PyExc_TypeError,
 			"OSType arg must be string of 4 chars");
 		return 0;
 	}
-	memcpy((char *)pr, PyString_AsString(v), 4);
+	memcpy((char *)&tmp, PyString_AsString(v), 4);
+	*pr = (OSType)ntohl(tmp);
 	return 1;
 }
 
@@ -169,7 +171,8 @@
 PyObject *
 PyMac_BuildOSType(OSType t)
 {
-	return PyString_FromStringAndSize((char *)&t, 4);
+	uint32_t tmp = htonl((uint32_t)t);
+	return PyString_FromStringAndSize((char *)&tmp, 4);
 }
 
 /* Convert an NumVersion value to a 4-element tuple */
@@ -363,10 +366,10 @@
 \
 int routinename(PyObject *pyobj, object *cobj) { \
     if (!PyMacGluePtr_##routinename) { \
-       if (!PyImport_ImportModule(module)) return NULL; \
+       if (!PyImport_ImportModule(module)) return 0; \
        if (!PyMacGluePtr_##routinename) { \
            PyErr_SetString(PyExc_ImportError, "Module did not provide routine: " module ": " #routinename); \
-           return NULL; \
+           return 0; \
        } \
     } \
     return (*PyMacGluePtr_##routinename)(pyobj, cobj); \