summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/Python
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/scripts/Python')
-rw-r--r--lldb/scripts/Python/python-typemaps.swig11
1 files changed, 9 insertions, 2 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 * {
OpenPOWER on IntegriCloud