mirror of https://github.com/python/cpython
Added PyMac_BuildOptStr255, which returns None on a null pointer.
This commit is contained in:
parent
a07431f0ce
commit
b734adef4b
|
@ -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 */
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue