CodeSampleX

샘플

idna 3.18

검증된 샘플 — pypi idna 3.18. python 3.12 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: idna.encode converts internationalized domain names into Punycode…

sha256:bce9de5fa823c4532a9fb4215f76e656c0d92b22a1639f47a5d1ed881efb7868

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 linux 24 · ubuntu · glibc 2.39 x64 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-28

케이스

HOW
목표
verify pkg:pypi/idna@3.18
패키지
생성일
2026-08-28T04:15:13Z

컨트랙트

  1. idna.encode converts internationalized domain names into Punycode ASCII-compatible encoding bytes and preserves trailing dots
  2. idna.encode with uts46=True normalizes uppercase characters before encoding
  3. idna.encode raises IDNAError when domain is empty or contains empty labels
  4. idna.decode decodes Punycode byte sequences and string representations to Unicode domain strings
  5. idna.decode raises IDNAError on malformed Punycode labels
  6. idna.alabel and idna.ulabel convert individual domain labels between Unicode and ACE bytes
  7. idna.uts46_remap remaps and normalizes domain names following Unicode UTS 46
  8. idna.check_bidi validates bidirectional domain name labels

파일

  • PROMPT.md
  • csx.json
  • requirements.txt
  • spec.json
  • test/contract.py

소스 아티팩트 내려받기 (tar.gz)

소스

PROMPT.md
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.18
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/idna@3.18

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.
csx.json
{"case":{"caseId":"case:sha256:3918e0b6b4c2e273ac17009ef626df6acb629776761c29441963951adaaf4f1f","contract":["idna.encode converts internationalized domain names into Punycode ASCII-compatible encoding bytes and preserves trailing dots","idna.encode with uts46=True normalizes uppercase characters before encoding","idna.encode raises IDNAError when domain is empty or contains empty labels","idna.decode decodes Punycode byte sequences and string representations to Unicode domain strings","idna.decode raises IDNAError on malformed Punycode labels","idna.alabel and idna.ulabel convert individual domain labels between Unicode and ACE bytes","idna.uts46_remap remaps and normalizes domain names following Unicode UTS 46","idna.check_bidi validates bidirectional domain name labels"],"goal":"verify pkg:pypi/idna@3.18","kind":"HOW","packages":["pkg:pypi/idna@3.18"],"schemaVersion":1},"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.18"],"schemaVersion":1,"subject":"pkg:pypi/idna@3.18","verifierAdapter":"python@1"}
requirements.txt
idna==3.18
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:pypi/idna@3.18",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/idna@3.18"
  ]
}
test/contract.py
import idna
import idna.core


def test_encode() -> None:
    # 1. idna.encode converts internationalized domain names into Punycode ASCII-compatible encoding bytes and preserves trailing dots
    assert idna.encode("домен.is") == b"xn--d1acufc.is"
    assert idna.encode("example.com") == b"example.com"
    assert idna.encode("köln.de.") == b"xn--kln-sna.de."

    # 2. idna.encode with uts46=True normalizes uppercase characters before encoding
    assert idna.encode("KÖLN.de", uts46=True) == b"xn--kln-sna.de"

    # 3. idna.encode raises IDNAError when domain is empty or contains empty labels
    try:
        idna.encode("")
        raise AssertionError("Expected IDNAError for empty domain")
    except idna.IDNAError as exc:
        assert isinstance(exc, idna.IDNAError)

    try:
        idna.encode("a..b")
        raise AssertionError("Expected IDNAError for consecutive dots")
    except idna.IDNAError as exc:
        assert isinstance(exc, idna.IDNAError)


def test_decode() -> None:
    # 4. idna.decode decodes Punycode byte sequences and string representations to Unicode domain strings
    assert idna.decode(b"xn--d1acufc.is") == "домен.is"
    assert idna.decode("xn--kln-sna.de") == "köln.de"
    assert idna.decode(b"example.com.") == "example.com."

    # 5. idna.decode raises IDNAError on malformed Punycode labels
    try:
        idna.decode(b"xn--invalid_label_12345!")
        raise AssertionError("Expected IDNAError for malformed label")
    except idna.IDNAError as exc:
        assert isinstance(exc, idna.IDNAError)


def test_label_conversion() -> None:
    # 6. idna.alabel and idna.ulabel convert individual domain labels between Unicode and ACE bytes
    assert idna.alabel("köln") == b"xn--kln-sna"
    assert idna.ulabel(b"xn--kln-sna") == "köln"
    assert idna.ulabel("xn--kln-sna") == "köln"


def test_uts46_remap() -> None:
    # 7. idna.uts46_remap remaps and normalizes domain names following Unicode UTS 46
    assert idna.uts46_remap("EXAMPLE.COM") == "example.com"
    assert idna.uts46_remap("KÖLN.DE", std3_rules=True) == "köln.de"
    assert idna.uts46_remap("faß.de", transitional=False) == "faß.de"
    assert idna.uts46_remap("faß.de", transitional=True) == "fass.de"


def test_check_bidi() -> None:
    # 8. idna.check_bidi validates bidirectional domain name labels
    assert idna.check_bidi("abc") is True


def main() -> None:
    test_encode()
    test_decode()
    test_label_conversion()
    test_uts46_remap()
    test_check_bidi()
    print("All contract assertions passed.")


if __name__ == "__main__":
    main()

오리진 시더

익명