[Lldb-commits] [lldb] r253261 - Python3 - Fix some issues related to `PythonFile` class.

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Mon Nov 16 14:40:12 PST 2015


Author: zturner
Date: Mon Nov 16 16:40:12 2015
New Revision: 253261

URL: http://llvm.org/viewvc/llvm-project?rev=253261&view=rev
Log:
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.

Modified:
    lldb/trunk/scripts/Python/python-typemaps.swig
    lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp

Modified: lldb/trunk/scripts/Python/python-typemaps.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-typemaps.swig?rev=253261&r1=253260&r2=253261&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-typemaps.swig (original)
+++ lldb/trunk/scripts/Python/python-typemaps.swig Mon Nov 16 16:40:12 2015
@@ -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) {

Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp?rev=253261&r1=253260&r2=253261&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp (original)
+++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp Mon Nov 16 16:40:12 2015
@@ -1035,6 +1035,12 @@ PythonFile::Reset(PyRefType type, PyObje
 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,




More information about the lldb-commits mailing list