[BUG]: `json.dumps` failed on object with new `_pybind11_conduit_v1` method

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

メンテナーはふだん 4 日以内に返信

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
30/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
cpp, python

調査の方向性

まず、pybind11_conduit_v1 を持つ pybind11 バインドオブジェクトに対して Python's json.dumps(..., default=vars) を使い、失敗を再現します。次に、pybind11 2.13.5 と 2.13.6 の間で挙動を比較します。意図されたシリアライズの挙動と、2.13.6 の変更がリグレッションであるかどうかが明確に確立されれば完了です。

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

説明

triage
Required prerequisites
What version (or hash if on master) of pybind11 are you using?

2.13.6

Problem description

A new self._pybind11_conduit_v1_() method that is added to all classes by default breaks the serialization of this object through json.dumps([object with _pybind11_conduit_v1], default=vars). I would like to clarify whether this is by mistake or intentional, considering also that this is a patch release. Thanks!

The error:

  File "/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/triton/compiler/compiler.py", line 315, in compile
    metadata_group[metadata_filename] = fn_cache_manager.put(json.dumps(metadata, default=vars), metadata_filename,
  File "/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/json/__init__.py", line 234, in dumps
    return cls(
  File "/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
TypeError: vars() argument must have __dict__ attribute
Reproducible example code
Since this should be a problem with any object, and I have no experience with `pybind`, I will leave it without a reproducer for now, but if it is not so easy to reproduce, I may try to make one.
Is this a regression? Put the last known working version here if it is.

2.13.5

主要言語
C++
スター
18k
フォーク
2.3k
平均マージ
5日 7時間
マージ済み PR(30日)
53

環境構築

はじめの一歩

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

pybind/pybind11 のほかの issue

pybind/pybind11 の issue をすべて見る

似ている issue

C++ の issue をもっと見る

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

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