샘플
urllib3 2.7.0: exceptions.URLSchemeUnknown
검증된 샘플 — pypi urllib3 2.7.0: exceptions.URLSchemeUnknown. python 3.12 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: assert URLSchemeUnknown inherits…
sha256:5fbd9caacb21de3e2bbfae278c52f7de787ab8d59ff7a97ad019d2d03491c1f3
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 pip
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-06 |
케이스
HOW- 목표
- verify urllib3.exceptions.URLSchemeUnknown in pkg:pypi/urllib3@2.7.0
- 패키지
- 심벌
-
- urllib3.exceptions.URLSchemeUnknown
- 생성일
- 2026-09-06T00:39:28Z
컨트랙트
- assert URLSchemeUnknown inherits from LocationValueError, ValueError, and HTTPError
- assert URLSchemeUnknown stores the unsupported scheme string in its scheme attribute
- assert URLSchemeUnknown string representation formats as Not supported URL scheme followed by scheme
- assert PoolManager.connection_from_url raises URLSchemeUnknown when given an unsupported scheme
- assert PoolManager.connection_from_context raises URLSchemeUnknown when request context contains an unsupported scheme
- assert urllib3.request raises URLSchemeUnknown when called with an unsupported scheme URL
파일
- PROMPT.md
- csx.json
- pyproject.toml
- requirements.txt
- sample.py
- spec.json
- 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 urllib3.exceptions.URLSchemeUnknown in pkg:pypi/urllib3@2.7.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/urllib3@2.7.0
Demonstrate these symbols/APIs:
- urllib3.exceptions.URLSchemeUnknown
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:083f2e6905da0dfd5e1d814f65dc0e09b34f2b6f6b9acd4603721dba76436b18","contract":["assert URLSchemeUnknown inherits from LocationValueError, ValueError, and HTTPError","assert URLSchemeUnknown stores the unsupported scheme string in its scheme attribute","assert URLSchemeUnknown string representation formats as Not supported URL scheme followed by scheme","assert PoolManager.connection_from_url raises URLSchemeUnknown when given an unsupported scheme","assert PoolManager.connection_from_context raises URLSchemeUnknown when request context contains an unsupported scheme","assert urllib3.request raises URLSchemeUnknown when called with an unsupported scheme URL"],"goal":"verify urllib3.exceptions.URLSchemeUnknown in pkg:pypi/urllib3@2.7.0","kind":"HOW","packages":["pkg:pypi/urllib3@2.7.0"],"schemaVersion":1,"symbols":["urllib3.exceptions.URLSchemeUnknown"]},"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/urllib3@2.7.0"],"schemaVersion":1,"subject":"pkg:pypi/urllib3@2.7.0","symbols":["urllib3.exceptions.URLSchemeUnknown"],"verifierAdapter":"python@1"}
[project]
name = "verify-urllib3-urlschemeunknown"
version = "0.1.0"
dependencies = [
"urllib3==2.7.0",
]
urllib3==2.7.0
"""Demonstration of urllib3 URL scheme validation and URLSchemeUnknown exception handling."""
from typing import Any, Dict, Optional
import urllib3
from urllib3.exceptions import HTTPError, LocationValueError, URLSchemeUnknown
def get_connection_pool_for_url(
pool_manager: urllib3.PoolManager,
url: str,
) -> urllib3.connectionpool.HTTPConnectionPool:
"""Acquire a connection pool from PoolManager for the specified URL.
Raises URLSchemeUnknown if the URL has an unsupported scheme.
"""
return pool_manager.connection_from_url(url)
def get_connection_pool_for_context(
pool_manager: urllib3.PoolManager,
request_context: Dict[str, Any],
) -> urllib3.connectionpool.HTTPConnectionPool:
"""Acquire a connection pool based on request context dictionary.
Raises URLSchemeUnknown if the scheme in request_context is not supported.
"""
return pool_manager.connection_from_context(request_context)
def dispatch_request(method: str, url: str) -> Optional[urllib3.response.BaseHTTPResponse]:
"""Dispatch an HTTP request via urllib3.request.
Raises URLSchemeUnknown if the target URL has an unsupported scheme.
"""
return urllib3.request(method, url)
def is_url_scheme_unknown_error(exc: Exception) -> bool:
"""Check if an exception is an instance of URLSchemeUnknown and its expected base classes."""
return (
isinstance(exc, URLSchemeUnknown)
and isinstance(exc, LocationValueError)
and isinstance(exc, ValueError)
and isinstance(exc, HTTPError)
)
{
"schemaVersion": 1,
"goal": "verify urllib3.exceptions.URLSchemeUnknown in pkg:pypi/urllib3@2.7.0",
"kind": "HOW",
"packages": [
"pkg:pypi/urllib3@2.7.0"
],
"symbols": [
"urllib3.exceptions.URLSchemeUnknown"
]
}
"""Contract verification test for urllib3.exceptions.URLSchemeUnknown in pkg:pypi/urllib3@2.7.0."""
import os
import sys
# Ensure project root is on sys.path for local module imports
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import urllib3
from urllib3.exceptions import HTTPError, LocationValueError, URLSchemeUnknown
from sample import (
dispatch_request,
get_connection_pool_for_context,
get_connection_pool_for_url,
is_url_scheme_unknown_error,
)
def test_inheritance_hierarchy() -> None:
"""Assertion 1: assert URLSchemeUnknown inherits from LocationValueError, ValueError, and HTTPError."""
assert issubclass(URLSchemeUnknown, LocationValueError), "URLSchemeUnknown must inherit from LocationValueError"
assert issubclass(URLSchemeUnknown, ValueError), "URLSchemeUnknown must inherit from ValueError"
assert issubclass(URLSchemeUnknown, HTTPError), "URLSchemeUnknown must inherit from HTTPError"
def test_scheme_attribute() -> None:
"""Assertion 2: assert URLSchemeUnknown stores the unsupported scheme string in its scheme attribute."""
unsupported_scheme = "custom"
err = URLSchemeUnknown(unsupported_scheme)
assert err.scheme == unsupported_scheme, f"Expected scheme '{unsupported_scheme}', got '{err.scheme}'"
assert is_url_scheme_unknown_error(err), "err must be recognized by hierarchy check"
def test_string_representation() -> None:
"""Assertion 3: assert URLSchemeUnknown string representation formats as Not supported URL scheme followed by scheme."""
unsupported_scheme = "ftp"
err = URLSchemeUnknown(unsupported_scheme)
expected_message = f"Not supported URL scheme {unsupported_scheme}"
assert str(err) == expected_message, f"Expected '{expected_message}', got '{str(err)}'"
def test_pool_manager_connection_from_url() -> None:
"""Assertion 4: assert PoolManager.connection_from_url raises URLSchemeUnknown when given an unsupported scheme."""
pm = urllib3.PoolManager()
unsupported_url = "ftp://example.com/resource"
raised = False
try:
get_connection_pool_for_url(pm, unsupported_url)
except URLSchemeUnknown as exc:
raised = True
assert exc.scheme == "ftp", f"Expected scheme 'ftp', got '{exc.scheme}'"
assert is_url_scheme_unknown_error(exc), "Exception must satisfy inheritance checks"
assert raised, "PoolManager.connection_from_url should have raised URLSchemeUnknown"
def test_pool_manager_connection_from_context() -> None:
"""Assertion 5: assert PoolManager.connection_from_context raises URLSchemeUnknown when request context contains an unsupported scheme."""
pm = urllib3.PoolManager()
context = {"scheme": "gopher", "host": "example.com"}
raised = False
try:
get_connection_pool_for_context(pm, context)
except URLSchemeUnknown as exc:
raised = True
assert exc.scheme == "gopher", f"Expected scheme 'gopher', got '{exc.scheme}'"
assert is_url_scheme_unknown_error(exc), "Exception must satisfy inheritance checks"
assert raised, "PoolManager.connection_from_context should have raised URLSchemeUnknown"
def test_urllib3_request_unsupported_scheme() -> None:
"""Assertion 6: assert urllib3.request raises URLSchemeUnknown when called with an unsupported scheme URL."""
unsupported_url = "ssh://example.com/target"
raised = False
try:
dispatch_request("GET", unsupported_url)
except URLSchemeUnknown as exc:
raised = True
assert exc.scheme == "ssh", f"Expected scheme 'ssh', got '{exc.scheme}'"
assert is_url_scheme_unknown_error(exc), "Exception must satisfy inheritance checks"
assert raised, "urllib3.request should have raised URLSchemeUnknown"
def main() -> None:
test_inheritance_hierarchy()
test_scheme_attribute()
test_string_representation()
test_pool_manager_connection_from_url()
test_pool_manager_connection_from_context()
test_urllib3_request_unsupported_scheme()
print("All contract assertions passed.")
if __name__ == "__main__":
main()
오리진 시더
익명