샘플
pillow 12.3.0: PIL.UnidentifiedImageError
검증된 샘플 — pypi pillow 12.3.0: PIL.UnidentifiedImageError. python 3.12 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: PIL.UnidentifiedImageError is…
sha256:d975b954d8ef65fab90f8d30444e370d13b47b9e1980020451e64e7ac9717a7d
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
python linux 24 · ubuntu · glibc 2.39 x64 python 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-28 |
케이스
HOW- 목표
- verify PIL.UnidentifiedImageError in pkg:pypi/pillow@12.3.0
- 패키지
- 심벌
-
- PIL.UnidentifiedImageError
- 환경
- python
- 생성일
- 2026-08-28T04:23:25Z
컨트랙트
- PIL.UnidentifiedImageError is exported by both PIL and PIL.Image and inherits from OSError and Exception.
- Image.open() raises UnidentifiedImageError when given an empty byte stream (io.BytesIO(b"")).
- Image.open() raises UnidentifiedImageError when given arbitrary non-image binary or text data.
- Image.open() raises UnidentifiedImageError when the image format is not included in the allowed formats parameter list.
- Image.open() successfully loads valid image streams without raising UnidentifiedImageError.
파일
- NOTES.md
- PROMPT.md
- csx.json
- requirements.txt
- spec.json
- test/contract.py
소스
# PIL.UnidentifiedImageError in Pillow
This sample pins `pillow` 12.3.0 and verifies `PIL.UnidentifiedImageError` when attempting to open unrecognized, empty, or format-restricted image data.
The contract verifies:
- `PIL.UnidentifiedImageError` is exported by both `PIL` and `PIL.Image` and inherits from `OSError` and `Exception`.
- `Image.open()` raises `UnidentifiedImageError` when given an empty byte stream (`io.BytesIO(b"")`).
- `Image.open()` raises `UnidentifiedImageError` when given arbitrary non-image binary or text data.
- `Image.open()` raises `UnidentifiedImageError` when the image format is not included in the allowed `formats` parameter list.
- `Image.open()` successfully loads valid image streams without raising `UnidentifiedImageError`.
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 PIL.UnidentifiedImageError in pkg:pypi/pillow@12.3.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:pypi/pillow@12.3.0
Demonstrate these symbols/APIs:
- PIL.UnidentifiedImageError
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:e5fd520d31f724b945820e114a6e87bf563f14ea99052a07e74d47bc014db84f","contract":["PIL.UnidentifiedImageError is exported by both PIL and PIL.Image and inherits from OSError and Exception.","Image.open() raises UnidentifiedImageError when given an empty byte stream (io.BytesIO(b\"\")).","Image.open() raises UnidentifiedImageError when given arbitrary non-image binary or text data.","Image.open() raises UnidentifiedImageError when the image format is not included in the allowed formats parameter list.","Image.open() successfully loads valid image streams without raising UnidentifiedImageError."],"goal":"verify PIL.UnidentifiedImageError in pkg:pypi/pillow@12.3.0","kind":"HOW","packages":["pkg:pypi/pillow@12.3.0"],"schemaVersion":1,"symbols":["PIL.UnidentifiedImageError"]},"contractCommand":["python","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","executionContext":"python","language":"python","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"pip","runtime":"python","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/pillow@12.3.0"],"schemaVersion":1,"subject":"pkg:pypi/pillow@12.3.0","symbols":["PIL.UnidentifiedImageError"],"verifierAdapter":"python@1"}
pillow==12.3.0
{
"schemaVersion": 1,
"goal": "verify PIL.UnidentifiedImageError in pkg:pypi/pillow@12.3.0",
"kind": "HOW",
"packages": [
"pkg:pypi/pillow@12.3.0"
],
"symbols": [
"PIL.UnidentifiedImageError"
]
}
import io
import PIL
from PIL import Image, UnidentifiedImageError
# 1. PIL.UnidentifiedImageError is exported by both PIL and PIL.Image and inherits from OSError and Exception.
assert hasattr(PIL, "UnidentifiedImageError"), "PIL must export UnidentifiedImageError"
assert hasattr(Image, "UnidentifiedImageError"), "PIL.Image must export UnidentifiedImageError"
assert PIL.UnidentifiedImageError is Image.UnidentifiedImageError
assert issubclass(UnidentifiedImageError, OSError), "UnidentifiedImageError must inherit from OSError"
assert issubclass(UnidentifiedImageError, Exception), "UnidentifiedImageError must inherit from Exception"
# 2. Image.open() raises UnidentifiedImageError when given an empty byte stream (io.BytesIO(b"")).
empty_stream = io.BytesIO(b"")
try:
Image.open(empty_stream)
raise AssertionError("Image.open() on empty stream did not raise UnidentifiedImageError")
except UnidentifiedImageError as exc:
assert isinstance(exc, OSError)
assert len(str(exc)) > 0
# 3. Image.open() raises UnidentifiedImageError when given arbitrary non-image binary or text data.
text_stream = io.BytesIO(b"Plain text payload - not a valid image format.")
try:
Image.open(text_stream)
raise AssertionError("Image.open() on text bytes did not raise UnidentifiedImageError")
except UnidentifiedImageError as exc:
assert isinstance(exc, UnidentifiedImageError)
assert isinstance(exc, OSError)
random_binary_stream = io.BytesIO(b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f")
try:
Image.open(random_binary_stream)
raise AssertionError("Image.open() on random bytes did not raise UnidentifiedImageError")
except UnidentifiedImageError as exc:
assert isinstance(exc, UnidentifiedImageError)
assert isinstance(exc, OSError)
# 4. Image.open() raises UnidentifiedImageError when the image format is not included in the allowed formats parameter list.
png_buffer = io.BytesIO()
img_temp = Image.new("RGB", (10, 10), color="blue")
img_temp.save(png_buffer, format="PNG")
img_temp.close()
png_buffer.seek(0)
try:
# Restrict allowed formats to JPEG only; opening PNG data must raise UnidentifiedImageError
Image.open(png_buffer, formats=["JPEG"])
raise AssertionError("Image.open() on PNG with formats=['JPEG'] did not raise UnidentifiedImageError")
except UnidentifiedImageError as exc:
assert isinstance(exc, UnidentifiedImageError)
assert isinstance(exc, OSError)
# 5. Image.open() successfully loads valid image streams without raising UnidentifiedImageError.
png_buffer.seek(0)
opened_img = Image.open(png_buffer)
assert opened_img.size == (10, 10)
assert opened_img.format == "PNG"
opened_img.close()
print("CONTRACT PASS: PIL.UnidentifiedImageError verified offline")
오리진 시더
익명