[BUG]: py::object.get_pointer() should use reinterpret_cast
メンテナーはふだん 4 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
調査の方向性
まず、py::object.get_pointer() の実装と、PyCapsule_GetPointer を使用しているコードパスを特定します。GCC で関数ポインターの例を再現し、その後、関数ポインターの場合がコンパイルでき、既存の capsule の動作が引き続き正しいことを確認します。
索引モデルが issue の本文から書いたものです。
説明
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
2.12.0
Problem description
The code for get_pointer() reads
T *result = static_cast<T *>(PyCapsule_GetPointer(m_ptr, name));
This makes it impossible to use get_pointer<f>() where f is a function type. I believe the right code should use reinterpret_cast. MSVC does not complain, but GCC breaks my code because of this.
Reproducible example code
//// Usual pybind headers and definitions
template <class f>
static void load_wrapper(py::dict &__pyx_capi__, const char *name,
f *&pointer) {
py::capsule wrapper = __pyx_capi__[name];
pointer = wrapper.get_pointer<f>();
}
double (*ddot_ptr)(int *n, double *zx, int *incx, double *zy, int *incy);
void load_scipy_wrappers() {
auto cython_blas = py::module_::import("scipy.linalg.cython_blas");
py::dict __pyx_capi__ = cython_blas.attr("__pyx_capi__");
load_wrapper(__pyx_capi__, "ddot", ddot_ptr);
}
Is this a regression? Put the last known working version here if it is.
Not a regression
- 主要言語
- C++
- スター
- 18k
- フォーク
- 2.3k
- 平均マージ
- 5日 7時間
- マージ済み PR(30日)
- 53
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pybind/pybind11 のほかの issue
-
triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 4 日以内に返信
-
triage
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
pybind/pybind11#5604 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信
-
triage
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 4 日以内に返信
-
docs
難易度 2/5 1〜3時間 初心者へのやさしさ 60/100
pybind/pybind11#747 · コメント 2 件 ·
メンテナーはふだん 4 日以内に返信
-
array_t::at() returns a misaligned reference when the stride is not a multiple of alignof(T)対応中かも @henryiii が今日担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
メンテナーはふだん 4 日以内に返信
pybind/pybind11 の issue をすべて見る
似ている issue
-
[Bug] Windows Ghidra provider rejects a PATH-only JDK: bare `java.exe` probe fails with Win32 87オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
tenstorrent/tt-umd#4084 ·
メンテナーはふだん 5 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
ToffelsKater/X4_VR#34 ·
-
difficulty:easy prio:low refactor
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
NatronGitHub/openfx-supportext#220 ·
メンテナーはふだん 1 日以内に返信