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

PyException cleanup #2597

merged 5 commits into from
Aug 2, 2024

Conversation

pepone
Copy link
Member

@pepone pepone commented Aug 1, 2024

No description provided.


void
IcePy::PyException::raiseLocalException()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merged raiseLocalException and raise


if (PyObject_IsInstance(ex.get(), userExceptionType))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer handel user exceptions in raise. TypedUpcall::exception always marshall user exceptions, and Invocation::unmarshalException unmarshall exceptions and validates exception specificiation. A user exception in PyException::raise doesn't have a special meaning.

Copy link
Member

@bernardnormier bernardnormier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we should remove the includeStackTrace parameter, because it should be always false. The message of an UnknownXxx exception should never include a stack trace.

}
else

string createUnknownExceptionMessage(PyObject* ex, PyObject* type, PyObject* tb, bool includeStackTrace)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we have an includeStackTrace parameter here (and by extension, the type and tb parameters).

The message for an UnknownException never includes the stack trace.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention was to include it when it is raised by the application, and not include it when it is raised by the remote peer.

throw Ice::UnknownLocalException{
__FILE__,
__LINE__,
createUnknownExceptionMessage(ex.get(), _type.get(), _tb.get(), includeStackTrace)};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should never include the stack trace here.

throw Ice::UnknownException{
__FILE__,
__LINE__,
createUnknownExceptionMessage(ex.get(), _type.get(), _tb.get(), includeStackTrace)};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@@ -89,7 +89,7 @@ namespace IcePy
//
// Convert the Python exception to its C++ equivalent.
//
void raise();
void raise(bool includeStackTrace);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From reading the code, that's not really what raise() does. It converts the Python exception into one of the 6 special Ice local exceptions. And as a result, we don't need an includeStackTrace parameter for this function.

@pepone
Copy link
Member Author

pepone commented Aug 1, 2024

Rewoked to never include stack trace with unknown exceptions.

@pepone pepone requested a review from bernardnormier August 1, 2024 16:24
}

void
IcePy::PyException::raise()
namespace IcePy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should use the same style as the rest:

string
IcePy::getTypeName(...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I move them to the .cpp file because they are local to this file. Updated the code to use tne anonymous namespace instead of IcePy to make it clear.

Copy link
Member

@bernardnormier bernardnormier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

}

void
IcePy::PyException::raise()
namespace IcePy
Copy link
Member

@bernardnormier bernardnormier Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you intend to use the anonymous namespace, and not reopen IcePy?

As far as I can tell, these functions are local to this file and not declared in the header.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@pepone pepone requested a review from externl August 2, 2024 07:19
@pepone pepone merged commit c7a05c0 into zeroc-ice:main Aug 2, 2024
18 checks passed
InsertCreativityHere pushed a commit to InsertCreativityHere/compiler-comparison that referenced this pull request Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants