python / python/cpython

ctypes should have an option to *not* catch c++ exceptions

オープン
#156,206 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

extension-modules OS-windows topic-ctypes type-feature
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Feature or enhancement

Proposal:

The ctypes module catches native exceptions and turns them into Python exceptions. In 99.99% of the cases this is exactly what you want, as a Python developer.

But the exception (pun unintended) is when the native exception is repeatable, but only happens in situations where you have no control.

An example is native exceptions that only occur when running your Python code which depends on numerous native libraries on the GitHub Windows runner. I have just had this happen to me for the third time in a couple of years. In the previous two cases the problem was some Python package (or native package it depends on) having a private copy of an outdated MSVC runtime library (or depending on some outdated copy). This is impossible to trace, because it is not repeatable on a development machine, and it isn't even repeatable when capturing the built folder and running the tests on you development machine.

Some mechanism (either a global method in ctypes to disable the exception-catching, or an environment variable PYTHON_CTYPES_DONT_CATCH_EXCEPTIONS) would help immensely, because I could use a debugging Python and a stack trace to pinpoint where the exception happens.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

ペイロードでは ctypes モジュールが示されていますが、ソースファイルもテストも示されていません。まず ctypes のネイティブな例外捕捉経路を特定し、現在の Python 例外変換がどのようにテストされているかを確認してください。グローバルスイッチと PYTHON_CTYPES_DONT_CATCH_EXCEPTIONS を比較し、デフォルトの動作を変更せずにデバッグ用にネイティブ例外を保持できる、文書化およびテスト済みの方法が存在することを完了条件としてください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
cpp, python
領域
backend, operating-systems
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。