[Lldb-commits] [lldb] r162228 - in /lldb/trunk: scripts/Python/python-typemaps.swig test/python_api/default-constructor/sb_debugger.py
Johnny Chen
johnny.chen at apple.com
Mon Aug 20 14:16:03 PDT 2012
Author: johnny
Date: Mon Aug 20 16:16:02 2012
New Revision: 162228
URL: http://llvm.org/viewvc/llvm-project?rev=162228&view=rev
Log:
Fix a crash (_wrap_SBDebugger_SetInputFileHandle -> PyString_AsString) running the test suite.
Also modify the boundary condition test case SBDebugger.DispatchInput(None) to be wrapped inside a try-except clause for now.
Modified:
lldb/trunk/scripts/Python/python-typemaps.swig
lldb/trunk/test/python_api/default-constructor/sb_debugger.py
Modified: lldb/trunk/scripts/Python/python-typemaps.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-typemaps.swig?rev=162228&r1=162227&r2=162228&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-typemaps.swig (original)
+++ lldb/trunk/scripts/Python/python-typemaps.swig Mon Aug 20 16:16:02 2012
@@ -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 * {
Modified: lldb/trunk/test/python_api/default-constructor/sb_debugger.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_debugger.py?rev=162228&r1=162227&r2=162228&view=diff
==============================================================================
--- lldb/trunk/test/python_api/default-constructor/sb_debugger.py (original)
+++ lldb/trunk/test/python_api/default-constructor/sb_debugger.py Mon Aug 20 16:16:02 2012
@@ -32,7 +32,10 @@
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())
More information about the lldb-commits
mailing list