Commit 4889327b authored by ussrhero's avatar ussrhero

fixed issue #6 ( wrong exception output if it description has special symbols )

parent 7a8748ee
...@@ -151,7 +151,7 @@ class PyObjectRef ...@@ -151,7 +151,7 @@ class PyObjectRef
{ {
public: public:
PyObjectRef() : m_obj(0) PyObjectRef() : m_obj(nullptr)
{} {}
PyObjectRef(PyObject* obj) PyObjectRef(PyObject* obj)
...@@ -170,6 +170,11 @@ public: ...@@ -170,6 +170,11 @@ public:
return m_obj; return m_obj;
} }
PyObject** operator&()
{
return &m_obj;
}
PyObjectRef& operator= (const PyObjectRef& ref) PyObjectRef& operator= (const PyObjectRef& ref)
{ {
if (m_obj) if (m_obj)
......
...@@ -580,8 +580,7 @@ pip( ...@@ -580,8 +580,7 @@ pip(
void handleException() void handleException()
{ {
// PyObjectRef errtype, errvalue, traceback;
PyObject *errtype = NULL, *errvalue = NULL, *traceback = NULL;
PyErr_Fetch(&errtype, &errvalue, &traceback); PyErr_Fetch(&errtype, &errvalue, &traceback);
...@@ -596,9 +595,9 @@ void handleException() ...@@ -596,9 +595,9 @@ void handleException()
PyObjectRef format_exception = PyObject_GetAttrString(traceback_module, "format_exception"); PyObjectRef format_exception = PyObject_GetAttrString(traceback_module, "format_exception");
PyObjectRef args = PyTuple_New(3); PyObjectRef args = PyTuple_New(3);
PyTuple_SetItem(args, 0, errtype ? errtype : Py_None()); PyTuple_SetItem(args, 0, errtype ? static_cast<PyObject*>(errtype) : Py_None());
PyTuple_SetItem(args, 1, errvalue ? errvalue : Py_None()); PyTuple_SetItem(args, 1, errvalue ? static_cast<PyObject*>(errvalue) : Py_None());
PyTuple_SetItem(args, 2, traceback ? traceback : Py_None()); PyTuple_SetItem(args, 2, traceback ? static_cast<PyObject*>(traceback) : Py_None());
PyObjectRef lst = PyObject_Call(format_exception, args, NULL); PyObjectRef lst = PyObject_Call(format_exception, args, NULL);
...@@ -612,10 +611,6 @@ void handleException() ...@@ -612,10 +611,6 @@ void handleException()
throw std::exception(sstr.str().c_str()); throw std::exception(sstr.str().c_str());
} }
if (errtype) Py_DecRef(errtype);
if (errvalue) Py_DecRef(errvalue);
if (traceback) Py_DecRef(traceback);
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -786,6 +781,10 @@ void printString(PDEBUG_CLIENT client, ULONG mask, const char* str) ...@@ -786,6 +781,10 @@ void printString(PDEBUG_CLIENT client, ULONG mask, const char* str)
if ( prefer_dml && mask == DEBUG_OUTPUT_ERROR ) if ( prefer_dml && mask == DEBUG_OUTPUT_ERROR )
{ {
line = std::regex_replace(line, std::regex("&"), "&amp;");
line = std::regex_replace(line, std::regex("<"), "&lt;");
line = std::regex_replace(line, std::regex(">"), "&gt;");
control->ControlledOutput( control->ControlledOutput(
DEBUG_OUTCTL_AMBIENT_DML, DEBUG_OUTCTL_AMBIENT_DML,
mask, mask,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment