From b734adef4b0a263bd28a94fbb6463e8295508926 Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Fri, 17 Dec 1999 17:15:50 +0000 Subject: Added PyMac_BuildOptStr255, which returns None on a null pointer. --- Mac/Include/macglue.h | 1 + Mac/Python/macglue.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/Mac/Include/macglue.h b/Mac/Include/macglue.h index 5e39044..bc1939f 100644 --- a/Mac/Include/macglue.h +++ b/Mac/Include/macglue.h @@ -105,6 +105,7 @@ PyObject *PyMac_BuildNumVersion(NumVersion); /* Convert NumVersion to PyObject * int PyMac_GetStr255(PyObject *, Str255); /* argument parser for Str255 */ PyObject *PyMac_BuildStr255(Str255); /* Convert Str255 to PyObject */ +PyObject *PyMac_BuildOptStr255(Str255); /* Convert Str255 to PyObject, NULL to None */ int PyMac_GetFSSpec(PyObject *, FSSpec *); /* argument parser for FSSpec */ PyObject *PyMac_BuildFSSpec(FSSpec *); /* Convert FSSpec to PyObject */ diff --git a/Mac/Python/macglue.c b/Mac/Python/macglue.c index 117911a..40cdfa2 100644 --- a/Mac/Python/macglue.c +++ b/Mac/Python/macglue.c @@ -826,6 +826,20 @@ PyMac_GetStr255(PyObject *v, Str255 pbuf) PyObject * PyMac_BuildStr255(Str255 s) { + if ( s == NULL ) { + PyErr_SetString(PyExc_SystemError, "Str255 pointer is NULL"); + return NULL; + } + return PyString_FromStringAndSize((char *)&s[1], (int)s[0]); +} + +PyObject * +PyMac_BuildOptStr255(Str255 s) +{ + if ( s == NULL ) { + Py_INCREF(Py_None); + return Py_None; + } return PyString_FromStringAndSize((char *)&s[1], (int)s[0]); } -- cgit v0.12