Skip to content

Remove unneeded code for handling zero-width characters - #9875

Merged
hugovk merged 1 commit into
python-pillow:mainfrom
radarhere:bdf
Aug 20, 2026
Merged

Remove unneeded code for handling zero-width characters#9875
hugovk merged 1 commit into
python-pillow:mainfrom
radarhere:bdf

Conversation

@radarhere

Copy link
Copy Markdown
Member

try:
im = Image.frombytes("1", (width, height), bitmap, "hex", "1")
except ValueError:
# deal with zero-width characters
im = Image.new("1", (width, height))

I don't think the exception handling is needed here.

It has been present since PIL. A test was added in #8783, but it was an artificial scenario to improve coverage, not a real need.

'deal with zero-width characters' would make you think that it would be needed for

Image.frombytes("1", (0, 0), b"", "hex", "1")
Image.frombytes("1", (0, 1), b"", "hex", "1")

but those lines don't raise an error.

@hugovk
hugovk merged commit d63b09f into python-pillow:main Aug 20, 2026
80 of 84 checks passed
@radarhere
radarhere deleted the bdf branch August 20, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants