CodeSampleX

Beispiel

cffi 2.0.0: Distinguish cffi string null-termination from unpack fixed-length extraction, pointer buffer sizing defaults, and cdata slice mutation semantics

Verifiziertes Beispiel für pypi cffi 2.0.0: Distinguish cffi string null-termination from unpack fixed-length extraction, pointer buffer sizing defaults, and…

sha256:da71aaaff2b56eff797ef7a598b2aa6bc8d2fe46f4271bcf2b957729ca9eead3

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
2
Signaturschlüssel, die es gebaut haben
2
Deklarierte Umgebung python linux x64 python python pip

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
python 3.12 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1
2026-08-17
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

Fall

HOW
Ziel
Distinguish cffi string null-termination from unpack fixed-length extraction, pointer buffer sizing defaults, and cdata slice mutation semantics
Pakete
Symbole
  • cffi.FFI.string
  • cffi.FFI.unpack
  • cffi.FFI.buffer
  • cffi.FFI.new
Umgebung
python
Erstellt
2026-08-17T13:58:48Z

Contract

  1. Calling ffi.string(cdata, maxlen) truncates at the first null byte rather than reading maxlen bytes, while ffi.unpack extracts the exact byte count across embedded nulls.
  2. ffi.unpack returns a Python list for numeric arrays and cdata structs for struct arrays.
  3. ffi.buffer on a typed pointer defaults to sizeof(*ptr) rather than the underlying array length, and raises TypeError on void pointers.
  4. Writing to an ffi.buffer slice mutates the underlying C struct memory in-place.
  5. ffi.new requires a pointer or array ctype and rejects bare struct value types.
  6. Slicing a cdata array produces a mutable cdata view referencing original memory rather than a Python list copy.
  7. ffi.string on wchar_t arrays returns str rather than bytes, while ffi.unpack returns str preserving embedded nulls.

Dateien

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

Quellartefakt herunterladen (tar.gz)

Ursprungs-Seeder

csx-seed