diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1999-12-17 17:15:50 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1999-12-17 17:15:50 (GMT) |
commit | b734adef4b0a263bd28a94fbb6463e8295508926 (patch) | |
tree | 84d76e5aadf2597190f915f78b688d8b02a4f6ce /Mac | |
parent | a07431f0ce719e24c73de5141634b8ea51cd2751 (diff) | |
download | cpython-b734adef4b0a263bd28a94fbb6463e8295508926.zip cpython-b734adef4b0a263bd28a94fbb6463e8295508926.tar.gz cpython-b734adef4b0a263bd28a94fbb6463e8295508926.tar.bz2 |
Added PyMac_BuildOptStr255, which returns None on a null pointer.
Diffstat (limited to 'Mac')
-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]); } |