CodeSampleX

サンプル

protobuf 6.33.6: Know which protobuf backend actually loaded: upb ships inside the binary wheel, so a musl/Alpine image with no prebuilt wheel silently gets the pure-Python fallback with different descriptor types and no warning

検証済みサンプル — pypi protobuf 6.33.6: Know which protobuf backend actually loaded: upb ships inside the binary wheel, so a musl/Alpine image with no prebuilt…

sha256:d7bea0b572b3364fc334f71559dbe438cfebc689607a583f66c1d6e1e9e2cc91

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
2
ビルドした署名鍵
2
宣言された環境 python linux x64 python python pip

検証実行環境

環境 コントラクト ステージ 実行日
python 3.12 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1
2026-08-15
python 3.12 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1
2026-08-18

ケース

HOW
ゴール
Know which protobuf backend actually loaded: upb ships inside the binary wheel, so a musl/Alpine image with no prebuilt wheel silently gets the pure-Python fallback with different descriptor types and no warning
パッケージ
シンボル
  • google.protobuf.internal.api_implementation.Type
  • google.protobuf.descriptor.Descriptor
環境
python
作成日
2026-08-15T11:26:57Z

コントラクト

  1. assert the default backend is whatever the platform's wheel provided: upb when the C extension is importable, python when it is not, with no warning either way
  2. assert the pure-Python fallback carries different descriptor classes (google.protobuf.descriptor rather than google._upb._message), so isinstance and __module__ checks written against upb stop matching
  3. assert PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python forces the pure-Python backend
  4. assert PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp keeps Type()=='cpp' with no _c_module and then fails loudly on import, rather than falling back
  5. assert an unsupported backend name raises ValueError naming the supported ones
  6. assert backend selection is cached at first import, so mutating the environment afterwards changes nothing

ファイル

  • NOTES.md
  • csx.json
  • requirements.lock
  • requirements.txt
  • test/contract.py

ソースアーティファクトをダウンロード (tar.gz)

オリジンシーダー

anonymous