Skip to content

Added context managers#5261

Merged
hugovk merged 2 commits intopython-pillow:masterfrom
radarhere:context_managers
Feb 13, 2021
Merged

Added context managers#5261
hugovk merged 2 commits intopython-pillow:masterfrom
radarhere:context_managers

Conversation

@radarhere
Copy link
Copy Markdown
Member

@radarhere radarhere commented Feb 11, 2021

This is because of https://pillow.readthedocs.io/en/stable/releasenotes/7.0.0.html#image-del

Implicitly closing the image’s underlying file in Image.del has been removed. Use a context manager or call close() instead to close the file in a deterministic way.

def short_header():
Image.open(BytesIO(img_file[:119]))
with Image.open(BytesIO(img_file[:119])):
pass
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's stick a directive to skip coverage on this line, it's intentionally unreachable (from an exception in Image.open)

@hugovk hugovk merged commit fdd8b68 into python-pillow:master Feb 13, 2021
@radarhere radarhere deleted the context_managers branch February 14, 2021 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants