diff options
author | Zachary Turner <zturner@google.com> | 2015-11-16 22:40:12 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2015-11-16 22:40:12 +0000 |
commit | 32ac147b00e4ffd9f5baddcfabc0fd84a12e9f86 (patch) | |
tree | 3b93e8fc46898759492518539c8d571dce5100f7 | |
parent | 5883a73f18b7fcbd92596f5a2504fcf7c65ea527 (diff) | |
download | bcm5719-llvm-32ac147b00e4ffd9f5baddcfabc0fd84a12e9f86.tar.gz bcm5719-llvm-32ac147b00e4ffd9f5baddcfabc0fd84a12e9f86.zip |
Python3 - Fix some issues related to `PythonFile` class.
Python 3 has lots of new debug asserts, and some of these were
firing on PythonFile. Specifically related to handling of invalid
files.
llvm-svn: 253261
-rw-r--r-- | lldb/scripts/Python/python-typemaps.swig | 5 | ||||
-rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/lldb/scripts/Python/python-typemaps.swig b/lldb/scripts/Python/python-typemaps.swig index ad8569a7cd9..9921c485162 100644 --- a/lldb/scripts/Python/python-typemaps.swig +++ b/lldb/scripts/Python/python-typemaps.swig @@ -552,6 +552,11 @@ File file($1, false); PythonFile py_file(file, mode); $result = py_file.release(); + if (!$result) + { + $result = Py_None; + Py_INCREF(Py_None); + } } %typemap(in) (const char* string, int len) { diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp index e3f84f53df0..3107677ee94 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp @@ -1035,6 +1035,12 @@ PythonFile::Reset(PyRefType type, PyObject *py_obj) void PythonFile::Reset(File &file, const char *mode) { + if (!file.IsValid()) + { + Reset(); + return; + } + char *cmode = const_cast<char *>(mode); #if PY_MAJOR_VERSION >= 3 Reset(PyRefType::Owned, |