mirror of
https://github.com/biojppm/rapidyaml.git
synced 2026-01-18 21:41:18 +01:00
Return None for empty csubstr.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
This commit is contained in:
16
api/ryml.i
16
api/ryml.i
@@ -93,13 +93,17 @@ using csubstr = c4::csubstr;
|
||||
|
||||
%typemap(out) c4::csubstr {
|
||||
#if defined(SWIGPYTHON)
|
||||
PyObject *obj = PyMemoryView_FromMemory((char*)$1.str, $1.len, PyBUF_READ);
|
||||
if( ! obj)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "could not get readonly memory from c4::csubstr - have you passed a str?");
|
||||
SWIG_fail;
|
||||
if($1.str == nullptr) {
|
||||
$result = Py_None;
|
||||
} else {
|
||||
PyObject *obj = PyMemoryView_FromMemory((char*)$1.str, $1.len, PyBUF_READ);
|
||||
if( ! obj)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "could not get readonly memory from c4::csubstr - have you passed a str?");
|
||||
SWIG_fail;
|
||||
}
|
||||
$result = obj;
|
||||
}
|
||||
$result = obj;
|
||||
#else
|
||||
#error no "out" typemap defined for this export language
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user