diff options
-rw-r--r-- | Mac/Include/macglue.h | 1 | ||||
-rw-r--r-- | Mac/Python/macglue.c | 14 |
2 files changed, 15 insertions, 0 deletions
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]); } |