[Python-bugs-list] [ python-Bugs-489872 ] PyString_FromString(NULL) seg faults
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 06 Dec 2001 07:25:59 -0800
Bugs item #489872, was opened at 2001-12-06 07:25
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=489872&group_id=5470
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: John Merritt (jmerritt5)
Assigned to: Nobody/Anonymous (nobody)
Summary: PyString_FromString(NULL) seg faults
Initial Comment:
Python 1.5.4 and Python 2.0.1, the only two I have
installed, produce a segmentation violation when a NULL
is passed to, at least, PyString_FromString.
The solution is to check the argument and return
Py_None.
I saw in FAQ (wizard) 8.16 that you should return
Py_Build(""), but, on Python 1.5.4, I don't have
Py_Build.
I use SWIG 1.3.*, and I have modified my version of
SWIG to generate code to check the arguement prior to
calling PyString_FromString.
if (result == NULL) return Py_None;
resultobj = PyString_FromString(result);
return resultobj;
This works like a charm.
John
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=489872&group_id=5470