SFTtech / openage

Free (as in freedom) open source clone of the Age of Empires II engine 🚀
http://openage.dev
Other
12.78k stars 1.12k forks source link

Propagate C++ expections in Python (again) #1700

Open heinezen opened 1 month ago

heinezen commented 1 month ago

Problem Description

In https://github.com/SFTtech/openage/pull/1697 we removed the old method for adding C++ backtraces to Python, since Python's _PyTraceback_Add is no longer part of the public API.

An even older solution that we used before https://github.com/SFTtech/openage/pull/1496 also doesn't work anymore. We should find a better way to propagate backtraces that do not depend on unstable Python features.

Solutions?

We could solve this in several ways:

  1. Print the C++ exception backtrace in the C++ code, then forward the exception to Python and raise a Python exception
  2. Forward the C++ message to Python and include it in the Python exception message (this was proposed in https://github.com/python/cpython/issues/68931#issuecomment-1093689102)
  3. Do not forward C++ exceptions to Python and simply terminate in C++.