Ejemplo
idna 3.11: decode
Muestra verificada para pypi idna 3.11: decode. El contrato se ejecutó en python 3.12 · linux alpine/x64 · docker y pasó: idna.decode(s) decodes…
sha256:cf2476b91a1ff3ec7d8954be7b24d834de5079fe2c19fbde9bdd891d403b9030
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
- 1
Entorno declarado
linux 24 · ubuntu · glibc 2.39 x64 pip
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| python 3.12 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1python:3.12-alpine@sha256:d09d15e60962… |
2026-08-26 |
| python 3.12 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1python:3.12-slim@sha256:09f7da3bc104… |
2026-09-07 |
Caso
HOW- Objetivo
- verify idna.decode in pkg:pypi/idna@3.11
- Paquetes
- Símbolos
-
- idna.decode
- Creado
- 2026-08-26T04:36:23Z
Contrato
- idna.decode(s) decodes ASCII-compatible encoded (ACE/Punycode) domain name strings to Unicode
- idna.decode(s) accepts bytes and bytearray input representations
- idna.decode(s) returns plain ASCII domain names unchanged
- idna.decode(s) preserves trailing root domain dot
- idna.decode(s) decodes multiple internationalized domain labels separated by dots
- idna.decode(s) raises idna.IDNAError on malformed Punycode labels or leading dots
Archivos
- PROMPT.md
- csx.json
- requirements.txt
- spec.json
- src/domain_decoder.py
- test/contract.py
Código fuente
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify idna.decode in pkg:pypi/idna@3.11
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/idna@3.11
Demonstrate these symbols/APIs:
- idna.decode
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:51b83d55bd7c99d46ace6e1da3dd0fcac8ce3e38b18bab3668fb7dba5a67994c","contract":["idna.decode(s) decodes ASCII-compatible encoded (ACE/Punycode) domain name strings to Unicode","idna.decode(s) accepts bytes and bytearray input representations","idna.decode(s) returns plain ASCII domain names unchanged","idna.decode(s) preserves trailing root domain dot","idna.decode(s) decodes multiple internationalized domain labels separated by dots","idna.decode(s) raises idna.IDNAError on malformed Punycode labels or leading dots"],"goal":"verify idna.decode in pkg:pypi/idna@3.11","kind":"HOW","packages":["pkg:pypi/idna@3.11"],"schemaVersion":1,"symbols":["idna.decode"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/idna@3.11"],"schemaVersion":1,"subject":"pkg:pypi/idna@3.11","symbols":["idna.decode"],"verifierAdapter":"python@1"}
idna==3.11
{
"schemaVersion": 1,
"goal": "verify idna.decode in pkg:pypi/idna@3.11",
"kind": "HOW",
"packages": [
"pkg:pypi/idna@3.11"
],
"symbols": [
"idna.decode"
]
}
"""Domain name decoding module demonstrating idna.decode."""
from typing import Union
import idna
def decode_domain(domain: Union[str, bytes, bytearray], uts46: bool = False, strict: bool = False) -> str:
"""Decode an ASCII-compatible encoded (ACE/Punycode) domain name to Unicode.
Args:
domain: Domain name as str, bytes, or bytearray.
uts46: Enable UTS#46 compatibility processing.
strict: Enforce strict IDNA2008 validation rules.
Returns:
Decoded Unicode domain name.
Raises:
idna.IDNAError: If domain contains invalid Punycode or violates IDNA rules.
"""
return idna.decode(domain, uts46=uts46, strict=strict)
"""Contract verification test for idna.decode."""
import os
import sys
# Ensure repository root is on sys.path
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import idna
from src.domain_decoder import decode_domain
def test_decode_punycode_str():
# idna.decode(s) decodes ASCII-compatible encoded (ACE/Punycode) domain name strings to Unicode
ace_domain = "xn--bcher-kva.example"
expected = "bücher.example"
result = idna.decode(ace_domain)
assert result == expected, f"Expected {expected}, got {result}"
wrapped = decode_domain(ace_domain)
assert wrapped == expected, f"Expected {expected}, got {wrapped}"
def test_decode_bytes_and_bytearray():
# idna.decode(s) accepts bytes and bytearray input representations
expected = "bücher.example"
bytes_input = b"xn--bcher-kva.example"
result_bytes = idna.decode(bytes_input)
assert result_bytes == expected, f"Expected {expected}, got {result_bytes}"
bytearray_input = bytearray(b"xn--bcher-kva.example")
result_bytearray = idna.decode(bytearray_input)
assert result_bytearray == expected, f"Expected {expected}, got {result_bytearray}"
assert decode_domain(bytes_input) == expected
assert decode_domain(bytearray_input) == expected
def test_decode_plain_ascii():
# idna.decode(s) returns plain ASCII domain names unchanged
ascii_domain = "example.com"
result = idna.decode(ascii_domain)
assert result == "example.com", f"Expected 'example.com', got {result}"
assert decode_domain(ascii_domain) == "example.com"
def test_decode_preserve_trailing_dot():
# idna.decode(s) preserves trailing root domain dot
trailing = "xn--bcher-kva.example."
assert idna.decode(trailing) == "bücher.example."
assert decode_domain(trailing) == "bücher.example."
def test_decode_multiple_labels():
# idna.decode(s) decodes multiple internationalized domain labels separated by dots
multi_label = "xn--mnchen-3ya.xn--bcher-kva.de"
expected = "münchen.bücher.de"
result = idna.decode(multi_label)
assert result == expected, f"Expected {expected}, got {result}"
assert decode_domain(multi_label) == expected
def test_decode_malformed_punycode_raises_idna_error():
# idna.decode(s) raises idna.IDNAError on malformed Punycode labels or leading dots
invalid_inputs = ["xn--", "xn--invalid!label", "..", ".xn--bcher-kva.example"]
for item in invalid_inputs:
try:
idna.decode(item)
assert False, f"Expected idna.IDNAError for {item!r}"
except idna.IDNAError:
pass
try:
decode_domain(item)
assert False, f"Expected idna.IDNAError for decode_domain({item!r})"
except idna.IDNAError:
pass
def main():
test_decode_punycode_str()
test_decode_bytes_and_bytearray()
test_decode_plain_ascii()
test_decode_preserve_trailing_dot()
test_decode_multiple_labels()
test_decode_malformed_punycode_raises_idna_error()
print("Contract verification for idna.decode passed.")
return 0
if __name__ == "__main__":
sys.exit(main())
Seeder de origen
anónimo