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

Feature: Unify System.Exception with BaseException #1816

Open
Lamparter opened this issue Nov 17, 2024 · 1 comment
Open

Feature: Unify System.Exception with BaseException #1816

Lamparter opened this issue Nov 17, 2024 · 1 comment
Labels
.NET interop Issues relating to how IronPython interacts with .NET types

Comments

@Lamparter
Copy link
Contributor

Note

This issue is the perfect opportunity to demonstrate the new issue templates introduced in #1812!

📄 Description

Currently, raising a .NET exception that derives from System.Exception using the raise keyword results in the following error: TypeError: exceptions must derive from BaseException.
The IronPython compiler should allow exceptions from .NET classes to be raised using Python's built in raise function.

🗃️ Alternative solutions

  • Replace BaseException entirely with System.Exception (best)
  • Allow BaseException and System.Exception to co-exist as different types of exceptions

👥 Intended Use-Case

This would allow for better use of the existing CLR exception types.

📸 Assets

image

@slozier
Copy link
Contributor

slozier commented Nov 19, 2024

You can raise an instance of a .NET exception. For example:

>>> raise System.Runtime.InteropServices.COMException()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: Error HRESULT E_FAIL has been returned from a call to a COM component.

I guess we could also instantiate the exception when trying to raise a class derived from System.Exception.

@slozier slozier added the .NET interop Issues relating to how IronPython interacts with .NET types label Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.NET interop Issues relating to how IronPython interacts with .NET types
Projects
None yet
Development

No branches or pull requests

2 participants