샘플
idna 3.11: encode, decode, uts46_remap
검증된 샘플 — pypi idna 3.11: encode, decode, uts46_remap. python 3.12 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: idna.encode(name) encodes…
sha256:83e5c7478ef0027bb13dc5b91856d889fb441dbd97985c2425e8ddfc504d5685
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 2
선언된 환경
python 3.12 linux 24 · alpine · musl 1.2 x64 python 3.12 python pip
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-23 |
| python 3.12 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · python@1python:3.12-alpine@sha256:d09d15e60962… |
2026-09-08 |
케이스
HOW- 목표
- verify pkg:pypi/idna@3.11
- 패키지
- 심벌
-
- encode
- decode
- uts46_remap
- 환경
- python 3.12
- 생성일
- 2026-08-23T18:22:06Z
컨트랙트
- idna.encode(name) encodes internationalized domain names into Punycode bytes
- idna.decode(bytes) decodes Punycode byte sequences into Unicode domain strings
- idna.uts46_remap(domain) remaps and normalizes domain names following UTS 46
- idna.encode(name) raises IDNAError when domain labels are invalid or empty
파일
- PROMPT.md
- csx.json
- requirements.txt
- spec.json
- src/domain_codec.py
- test/contract.py
소스
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 pkg:pypi/idna@3.11
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/idna@3.11
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:f050b8b578c60c7b7d32bb5960ecf9a5a33d4acdf3b3a85363f201510ef0a28d","contract":["idna.encode(name) encodes internationalized domain names into Punycode bytes","idna.decode(bytes) decodes Punycode byte sequences into Unicode domain strings","idna.uts46_remap(domain) remaps and normalizes domain names following UTS 46","idna.encode(name) raises IDNAError when domain labels are invalid or empty"],"goal":"verify pkg:pypi/idna@3.11","kind":"HOW","packages":["pkg:pypi/idna@3.11"],"schemaVersion":1,"symbols":["encode","decode","uts46_remap"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"alpine","ecosystem":"pypi","language":"python","libc":"musl","libcVersion":"1.2","os":"linux","osVersionBucket":"24","packageManager":"pip","runtime":"python","runtimeVersion":"3.12","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/idna@3.11"],"schemaVersion":1,"subject":"pkg:pypi/idna@3.11","symbols":["encode","decode","uts46_remap"],"verifierAdapter":"python@1"}
idna==3.11
{
"schemaVersion": 1,
"goal": "verify pkg:pypi/idna@3.11",
"kind": "HOW",
"packages": [
"pkg:pypi/idna@3.11"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
"""Domain encoding and decoding module demonstrating idna library functions."""
import idna
def encode_domain(domain_name: str) -> bytes:
"""Encode an internationalized domain name into IDNA 2008 / Punycode bytes.
Args:
domain_name: Unicode domain name string.
Returns:
ASCII bytes representation of the domain name.
Raises:
idna.IDNAError: If the domain name or label violates IDNA rules.
"""
return idna.encode(domain_name)
def decode_domain(domain_bytes: bytes) -> str:
"""Decode IDNA 2008 / Punycode byte sequence back to a Unicode domain name string.
Args:
domain_bytes: ASCII bytes or bytearray of the Punycode domain name.
Returns:
Decoded Unicode domain name string.
Raises:
idna.IDNAError: If the Punycode sequence is invalid.
"""
return idna.decode(domain_bytes)
def normalize_domain(domain_name: str) -> str:
"""Normalize and remap a domain name string using UTS 46 rules.
Args:
domain_name: Unicode domain name string.
Returns:
Remapped and normalized domain name string.
Raises:
idna.IDNAError: If the domain name contains prohibited codepoints under UTS 46.
"""
return idna.uts46_remap(domain_name)
"""Contract verification test for pkg:pypi/idna@3.11."""
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_codec import decode_domain, encode_domain, normalize_domain
def test_encode():
# Internationalized domain name with non-ASCII characters
unicode_domain = "bücher.example"
encoded = encode_domain(unicode_domain)
assert isinstance(encoded, bytes), f"Expected bytes, got {type(encoded)}"
assert encoded == b"xn--bcher-kva.example", f"Unexpected encoded value: {encoded}"
# Direct library call
direct_encoded = idna.encode("münchen.example")
assert direct_encoded == b"xn--mnchen-3ya.example", f"Unexpected encoded value: {direct_encoded}"
# Pure ASCII domain name
ascii_domain = "example.com"
encoded_ascii = encode_domain(ascii_domain)
assert encoded_ascii == b"example.com", f"Unexpected encoded ASCII value: {encoded_ascii}"
def test_decode():
# Punycode byte sequence decoded back to unicode
punycode_bytes = b"xn--bcher-kva.example"
decoded = decode_domain(punycode_bytes)
assert isinstance(decoded, str), f"Expected str, got {type(decoded)}"
assert decoded == "bücher.example", f"Unexpected decoded value: {decoded}"
# Direct library call with bytes and str
direct_decoded = idna.decode(b"xn--mnchen-3ya.example")
assert direct_decoded == "münchen.example", f"Unexpected decoded value: {direct_decoded}"
# ASCII domain decoding
ascii_bytes = b"example.com"
decoded_ascii = decode_domain(ascii_bytes)
assert decoded_ascii == "example.com", f"Unexpected decoded ASCII value: {decoded_ascii}"
def test_uts46_remap():
# Normalizing mixed-case internationalized domain
raw_domain = "Bücher.Example"
remapped = normalize_domain(raw_domain)
assert isinstance(remapped, str), f"Expected str, got {type(remapped)}"
assert remapped == "bücher.example", f"Unexpected remapped value: {remapped}"
# Direct library call
direct_remapped = idna.uts46_remap("EXAMPLE.COM")
assert direct_remapped == "example.com", f"Unexpected remapped value: {direct_remapped}"
def test_error_handling():
# Empty label / invalid double dots
try:
encode_domain("invalid..domain")
assert False, "Expected IDNAError on invalid domain name"
except idna.IDNAError:
pass
# Invalid Punycode A-label decoding
try:
decode_domain(b"xn--invalid_label!!!")
assert False, "Expected IDNAError on invalid A-label"
except idna.IDNAError:
pass
def main():
test_encode()
test_decode()
test_uts46_remap()
test_error_handling()
print("Contract tests for pkg:pypi/idna@3.11 passed successfully.")
return 0
if __name__ == "__main__":
sys.exit(main())
오리진 시더
익명