Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Add deprecation of Image.__del__ #3929

Merged
merged 2 commits into from Jul 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/deprecations.rst
Expand Up @@ -12,6 +12,29 @@ Deprecated features
Below are features which are considered deprecated. Where appropriate,
a ``DeprecationWarning`` is issued.

Image.__del__
~~~~~~~~~~~~~

.. deprecated:: 6.1.0

Implicitly closing the image's underlying file in ``Image.__del__`` has been deprecated.
Use a context manager or call ``Image.close()`` instead to close the file in a
deterministic way.

Deprecated:

.. code-block:: python

im = Image.open("hopper.png")
im.save("out.jpg")

Use instead:

.. code-block:: python

with Image.open("hopper.png") as im:
im.save("out.jpg")

Python 2.7
~~~~~~~~~~

Expand Down
26 changes: 26 additions & 0 deletions docs/releasenotes/6.1.0.rst
@@ -1,6 +1,32 @@
6.1.0
-----

Deprecations
============

Image.__del__
^^^^^^^^^^^^^

.. deprecated:: 6.1.0

Implicitly closing the image's underlying file in ``Image.__del__`` has been deprecated.
Use a context manager or call ``Image.close()`` instead to close the file in a
deterministic way.

Deprecated:

.. code-block:: python

im = Image.open("hopper.png")
im.save("out.jpg")

Use instead:

.. code-block:: python

with Image.open("hopper.png") as im:
im.save("out.jpg")

API Additions
=============

Expand Down