CodeSampleX

Ejemplo

wrapt 2.2.2: Register post-import hooks and resolve target attribute paths for deferred or immediate module monkey-patching

Muestra verificada para pypi wrapt 2.2.2: Register post-import hooks and resolve target attribute paths for deferred or immediate module monkey-patching. El…

sha256:af57dbec1640ac0b0db78fcb6d980b05450f08ba22cb0c541017566924aa9cd9

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
2
Claves de firma que lo compilaron
2
Entorno declarado python linux x64 python python pip

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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

Caso

HOW
Objetivo
Register post-import hooks and resolve target attribute paths for deferred or immediate module monkey-patching
Paquetes
Símbolos
  • wrapt.register_post_import_hook
  • wrapt.when_imported
  • wrapt.resolve_path
  • wrapt.patch_function_wrapper
  • wrapt.apply_patch
  • wrapt.notify_module_loaded
Entorno
python
Creado
2026-08-17T13:15:00Z

Contrato

  1. wrapt.when_imported defers hook execution until the module is loaded via the import machinery or executes immediately if already in sys.modules
  2. assert multiple registered post-import hooks execute sequentially in order of registration
  3. assert wrapt.resolve_path returns a tuple of parent object, attribute name, and target reference for dotted target strings
  4. assert wrapt.resolve_path raises AttributeError when resolving non-existent path segments
  5. assert @wrapt.patch_function_wrapper installs a 4-argument wrapper on a resolved target function in-place
  6. assert wrapt.apply_patch replaces the attribute on the parent namespace and allows unpatching to the original target
  7. assert wrapt.notify_module_loaded triggers pending hooks for manually instantiated module objects

Archivos

  • NOTES.md
  • csx.json
  • requirements.txt
  • src/__init__.py
  • src/hook_manager.py
  • src/services.py
  • test/__init__.py
  • test/contract.py

Descargar el artefacto de código fuente (tar.gz)

Seeder de origen

csx-seed