Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyException cleanup #2597

Merged
merged 5 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/modules/IcePy/BatchRequestInterceptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,6 @@ IcePy::BatchRequestInterceptorWrapper::enqueue(const Ice::BatchRequest& request,
Py_DECREF(reinterpret_cast<PyObject*>(obj));
if (!tmp.get())
{
throwPythonException();
throwPythonException(true);
}
}
2 changes: 1 addition & 1 deletion python/modules/IcePy/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace IcePy
//
ex.checkSystemExit();

ex.raise();
ex.raise(true);
}
}

Expand Down
2 changes: 1 addition & 1 deletion python/modules/IcePy/Dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,6 @@ IcePy::Dispatcher::dispatch(function<void()> call, const Ice::ConnectionPtr& con
Py_DECREF(reinterpret_cast<PyObject*>(obj));
if (!tmp.get())
{
throwPythonException();
throwPythonException(false);
}
}
12 changes: 6 additions & 6 deletions python/modules/IcePy/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ IcePy::LoggerWrapper::print(const string& message)
PyObjectHandle tmp = PyObject_CallMethod(_logger.get(), "_print", "s", message.c_str());
if (!tmp.get())
{
throwPythonException();
throwPythonException(false);
}
}

Expand All @@ -44,7 +44,7 @@ IcePy::LoggerWrapper::trace(const string& category, const string& message)
PyObjectHandle tmp = PyObject_CallMethod(_logger.get(), "trace", "ss", category.c_str(), message.c_str());
if (!tmp.get())
{
throwPythonException();
throwPythonException(false);
}
}

Expand All @@ -56,7 +56,7 @@ IcePy::LoggerWrapper::warning(const string& message)
PyObjectHandle tmp = PyObject_CallMethod(_logger.get(), "warning", "s", message.c_str());
if (!tmp.get())
{
throwPythonException();
throwPythonException(false);
}
}

Expand All @@ -68,7 +68,7 @@ IcePy::LoggerWrapper::error(const string& message)
PyObjectHandle tmp = PyObject_CallMethod(_logger.get(), "error", "s", message.c_str());
if (!tmp.get())
{
throwPythonException();
throwPythonException(false);
}
}

Expand All @@ -80,7 +80,7 @@ IcePy::LoggerWrapper::getPrefix()
PyObjectHandle tmp = PyObject_CallMethod(_logger.get(), "getPrefix", 0);
if (!tmp.get())
{
throwPythonException();
throwPythonException(false);
}
return getString(tmp.get());
}
Expand All @@ -93,7 +93,7 @@ IcePy::LoggerWrapper::cloneWithPrefix(const string& prefix)
PyObjectHandle tmp = PyObject_CallMethod(_logger.get(), "cloneWithPrefix", "s", prefix.c_str());
if (!tmp.get())
{
throwPythonException();
throwPythonException(false);
}

return make_shared<LoggerWrapper>(tmp.get());
Expand Down
8 changes: 4 additions & 4 deletions python/modules/IcePy/ObjectAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ IcePy::ServantLocatorWrapper::locate(const Ice::Current& current, shared_ptr<voi
c->current = createCurrent(current);
if (!c->current)
{
throwPythonException();
throwPythonException(false);
}

//
Expand All @@ -156,7 +156,7 @@ IcePy::ServantLocatorWrapper::locate(const Ice::Current& current, shared_ptr<voi
throw ExceptionWriter(ex.ex);
}

ex.raise();
ex.raise(false);
}

if (res.get() == Py_None)
Expand Down Expand Up @@ -241,7 +241,7 @@ IcePy::ServantLocatorWrapper::finished(const Ice::Current&, const Ice::ObjectPtr
throw ExceptionWriter(ex.ex);
}

ex.raise();
ex.raise(false);
}
}

Expand All @@ -263,7 +263,7 @@ IcePy::ServantLocatorWrapper::deactivate(const string& category)
//
ex.checkSystemExit();

ex.raise();
ex.raise(false);
}
}

Expand Down
40 changes: 20 additions & 20 deletions python/modules/IcePy/Operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ namespace
return *obj->op;
}

void handleException()
void handleException(bool includeStackTrace)
{
assert(PyErr_Occurred());

Expand All @@ -320,7 +320,7 @@ namespace
//
ex.checkSystemExit();

ex.raise();
ex.raise(includeStackTrace);
}
}

Expand Down Expand Up @@ -859,7 +859,7 @@ Operation::marshalResult(Ice::OutputStream& os, PyObject* result)
{
try
{
PyException().raise();
throwPythonException(false);
}
catch (const Ice::UnknownException& ex)
{
Expand All @@ -879,7 +879,7 @@ Operation::marshalResult(Ice::OutputStream& os, PyObject* result)
{
try
{
PyException().raise();
throwPythonException(false);
}
catch (const Ice::UnknownException& ex)
{
Expand Down Expand Up @@ -1857,7 +1857,7 @@ IcePy::AsyncInvocation::response(bool ok, pair<const byte*, const byte*> results
handleResponse(future.get(), ok, results);
if (PyErr_Occurred())
{
handleException();
handleException(true);
}
}

Expand Down Expand Up @@ -1886,7 +1886,7 @@ IcePy::AsyncInvocation::exception(std::exception_ptr ex)
PyObjectHandle tmp = callMethod(future.get(), "set_exception", exh.get());
if (PyErr_Occurred())
{
handleException();
handleException(true);
}
}

Expand Down Expand Up @@ -1924,7 +1924,7 @@ IcePy::AsyncInvocation::sent(bool sentSynchronously)
PyObjectHandle tmp = callMethod(future.get(), "set_sent", sentSynchronously ? Py_True : Py_False);
if (PyErr_Occurred())
{
handleException();
handleException(true);
}

if (!_twoway)
Expand All @@ -1935,7 +1935,7 @@ IcePy::AsyncInvocation::sent(bool sentSynchronously)
tmp = callMethod(future.get(), "set_result", Py_None);
if (PyErr_Occurred())
{
handleException();
handleException(true);
}
}
}
Expand Down Expand Up @@ -2117,7 +2117,7 @@ IcePy::SyncBlobjectInvocation::invoke(PyObject* args, PyObject* /* kwds */)
PyObjectHandle result = PyTuple_New(2);
if (!result.get())
{
throwPythonException();
throwPythonException(true);
}

PyTuple_SET_ITEM(result.get(), 0, ok ? Py_True : Py_False);
Expand All @@ -2133,7 +2133,7 @@ IcePy::SyncBlobjectInvocation::invoke(PyObject* args, PyObject* /* kwds */)
}
if (!op.get())
{
throwPythonException();
throwPythonException(true);
}

PyTuple_SET_ITEM(result.get(), 1, op.release()); // PyTuple_SET_ITEM steals a reference.
Expand Down Expand Up @@ -2271,13 +2271,13 @@ Upcall::dispatchImpl(PyObject* servant, const string& dispatchName, PyObject* ar
PyObjectHandle dispatchArgs = PyTuple_New(3);
if (!dispatchArgs.get())
{
throwPythonException();
throwPythonException(false);
}

DispatchCallbackObject* callback = dispatchCallbackNew(&DispatchCallbackType, 0, 0);
if (!callback)
{
throwPythonException();
throwPythonException(false);
}
callback->upcall = new UpcallPtr(shared_from_this());
PyTuple_SET_ITEM(dispatchArgs.get(), 0, reinterpret_cast<PyObject*>(callback)); // Steals a reference.
Expand Down Expand Up @@ -2329,7 +2329,7 @@ IcePy::TypedUpcall::dispatch(PyObject* servant, pair<const byte*, const byte*> i
PyObjectHandle args = PyTuple_New(count);
if (!args.get())
{
throwPythonException();
throwPythonException(false);
}

if (!_op->inParams.empty())
Expand Down Expand Up @@ -2391,7 +2391,7 @@ IcePy::TypedUpcall::dispatch(PyObject* servant, pair<const byte*, const byte*> i
}
catch (const AbortMarshaling&)
{
throwPythonException();
throwPythonException(false);
}
}

Expand Down Expand Up @@ -2431,7 +2431,7 @@ IcePy::TypedUpcall::response(PyObject* result)
{
try
{
throwPythonException();
throwPythonException(false);
}
catch (...)
{
Expand Down Expand Up @@ -2483,12 +2483,12 @@ IcePy::TypedUpcall::exception(PyException& ex)
}
else
{
ex.raise();
ex.raise(false);
}
}
catch (const AbortMarshaling&)
{
throwPythonException();
throwPythonException(false);
}
}
catch (...)
Expand Down Expand Up @@ -2520,7 +2520,7 @@ IcePy::BlobjectUpcall::dispatch(PyObject* servant, pair<const byte*, const byte*
PyObjectHandle args = PyTuple_New(count);
if (!args.get())
{
throwPythonException();
throwPythonException(false);
}

PyObjectHandle ip;
Expand Down Expand Up @@ -2584,7 +2584,7 @@ IcePy::BlobjectUpcall::response(PyObject* result)
{
try
{
throwPythonException();
throwPythonException(false);
}
catch (...)
{
Expand All @@ -2610,7 +2610,7 @@ IcePy::BlobjectUpcall::exception(PyException& ex)
//
ex.checkSystemExit();

ex.raise();
ex.raise(false);
}
catch (...)
{
Expand Down
4 changes: 2 additions & 2 deletions python/modules/IcePy/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ IcePy::ThreadHook::start()
PyObjectHandle tmp = PyObject_Call(_threadStart.get(), args.get(), 0);
if (!tmp.get())
{
throwPythonException();
throwPythonException(true);
}
}
}
Expand All @@ -60,7 +60,7 @@ IcePy::ThreadHook::stop()
PyObjectHandle tmp = PyObject_Call(_threadStop.get(), args.get(), 0);
if (!tmp.get())
{
throwPythonException();
throwPythonException(true);
}
}
}
Loading
Loading