SFTtech / SFTtech/openage

Propagate C++ expections in Python (again)

Open
#1,700 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bugfix improvement lang: cython
Dominant language
Python
Stars
14.4k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

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++.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing pull requests 1697 and 1496 to understand the removed and older approaches, then read the linked CPython issue discussion. The work is done when a stable approach for propagating C++ backtraces or messages to Python is selected and implemented without relying on unstable Python features.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.