diff options
-rw-r--r-- | lldb/scripts/Python/python-typemaps.swig | 11 | ||||
-rw-r--r-- | lldb/test/python_api/default-constructor/sb_debugger.py | 5 |
2 files changed, 13 insertions, 3 deletions
diff --git a/lldb/scripts/Python/python-typemaps.swig b/lldb/scripts/Python/python-typemaps.swig index 31364cac84e..c269795bf5a 100644 --- a/lldb/scripts/Python/python-typemaps.swig +++ b/lldb/scripts/Python/python-typemaps.swig @@ -351,9 +351,15 @@ } %typemap(in) FILE * { - if (!PyFile_Check($input)) { + if ($input == Py_None) + $1 = NULL; + else if (!PyFile_Check($input)) { int fd = PyObject_AsFileDescriptor($input); PyObject *py_mode = PyObject_GetAttrString($input, "mode"); + if (!py_mode) { + PyErr_SetString(PyExc_TypeError,"not a file-like object"); + return NULL; + } const char *mode = PyString_AsString(py_mode); if (-1 != fd && mode) { FILE *f; @@ -366,7 +372,8 @@ return NULL; } } - $1 = PyFile_AsFile($input); + else + $1 = PyFile_AsFile($input); } %typemap(out) FILE * { diff --git a/lldb/test/python_api/default-constructor/sb_debugger.py b/lldb/test/python_api/default-constructor/sb_debugger.py index fb52c4877ce..91440b26ed9 100644 --- a/lldb/test/python_api/default-constructor/sb_debugger.py +++ b/lldb/test/python_api/default-constructor/sb_debugger.py @@ -32,7 +32,10 @@ def fuzz_obj(obj): obj.GetSourceManager() obj.SetSelectedTarget(lldb.SBTarget()) obj.SetCurrentPlatformSDKRoot("tmp/sdk-root") - obj.DispatchInput(None, 0) + try: + obj.DispatchInput(None) + except Exception: + pass obj.DispatchInputInterrupt() obj.DispatchInputEndOfFile() obj.PushInputReader(lldb.SBInputReader()) |