Skip to content

Commit 4a7cf05

Browse files
authored
Merge pull request #7512 from hugovk/docs-link-exceptions
Docs: link exceptions to Python docs
2 parents bee9c59 + 8fe2016 commit 4a7cf05

16 files changed

+35
-33
lines changed

docs/deprecations.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Deprecated features
1010
-------------------
1111

1212
Below are features which are considered deprecated. Where appropriate,
13-
a ``DeprecationWarning`` is issued.
13+
a :py:exc:`DeprecationWarning` is issued.
1414

1515
PSFile
1616
~~~~~~
@@ -267,7 +267,7 @@ ImageFile.raise_ioerror
267267
.. deprecated:: 7.2.0
268268
.. versionremoved:: 9.0.0
269269

270-
``IOError`` was merged into ``OSError`` in Python 3.3.
270+
:py:exc:`IOError` was merged into :py:exc:`OSError` in Python 3.3.
271271
So, ``ImageFile.raise_ioerror`` has been removed.
272272
Use ``ImageFile.raise_oserror`` instead.
273273

@@ -293,9 +293,9 @@ im.offset
293293
``im.offset()`` has been removed, call :py:func:`.ImageChops.offset()` instead.
294294

295295
It was documented as deprecated in PIL 1.1.2,
296-
raised a ``DeprecationWarning`` since 1.1.5,
297-
an ``Exception`` since Pillow 3.0.0
298-
and ``NotImplementedError`` since 3.3.0.
296+
raised a :py:exc:`DeprecationWarning` since 1.1.5,
297+
an :py:exc:`Exception` since Pillow 3.0.0
298+
and :py:exc:`NotImplementedError` since 3.3.0.
299299

300300
Image.fromstring, im.fromstring and im.tostring
301301
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -307,9 +307,9 @@ Image.fromstring, im.fromstring and im.tostring
307307
* ``im.fromstring()`` has been removed, call :py:meth:`~PIL.Image.Image.frombytes()` instead.
308308
* ``im.tostring()`` has been removed, call :py:meth:`~PIL.Image.Image.tobytes()` instead.
309309

310-
They issued a ``DeprecationWarning`` since 2.0.0,
311-
an ``Exception`` since 3.0.0
312-
and ``NotImplementedError`` since 3.3.0.
310+
They issued a :py:exc:`DeprecationWarning` since 2.0.0,
311+
an :py:exc:`Exception` since 3.0.0
312+
and :py:exc:`NotImplementedError` since 3.3.0.
313313

314314
ImageCms.CmsProfile attributes
315315
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -318,7 +318,7 @@ ImageCms.CmsProfile attributes
318318
.. versionremoved:: 8.0.0
319319

320320
Some attributes in :py:class:`PIL.ImageCms.CmsProfile` have been removed. From 6.0.0,
321-
they issued a ``DeprecationWarning``:
321+
they issued a :py:exc:`DeprecationWarning`:
322322

323323
======================== ===================================================
324324
Removed Use instead
@@ -442,7 +442,7 @@ PIL.OleFileIO
442442
.. deprecated:: 4.0.0
443443
.. versionremoved:: 6.0.0
444444

445-
PIL.OleFileIO was removed as a vendored file in Pillow 4.0.0 (2017-01) in favour of
446-
the upstream :pypi:`olefile` Python package, and replaced with an ``ImportError`` in 5.0.0
445+
``PIL.OleFileIO`` was removed as a vendored file in Pillow 4.0.0 (2017-01) in favour of
446+
the upstream :pypi:`olefile` Python package, and replaced with an :py:exc:`ImportError` in 5.0.0
447447
(2018-01). The deprecated file has now been removed from Pillow. If needed, install from
448448
PyPI (eg. ``python3 -m pip install olefile``).

docs/reference/ImageFont.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ the imToolkit package.
2020

2121
.. warning::
2222
To protect against potential DOS attacks when using arbitrary strings as
23-
text input, Pillow will raise a ``ValueError`` if the number of characters
23+
text input, Pillow will raise a :py:exc:`ValueError` if the number of characters
2424
is over a certain limit, :py:data:`MAX_STRING_LENGTH`.
2525

2626
This threshold can be changed by setting
@@ -89,5 +89,5 @@ Constants
8989
.. data:: MAX_STRING_LENGTH
9090

9191
Set to 1,000,000, to protect against potential DOS attacks. Pillow will
92-
raise a ``ValueError`` if the number of characters is over this limit. The
92+
raise a :py:exc:`ValueError` if the number of characters is over this limit. The
9393
check can be disabled by setting ``ImageFont.MAX_STRING_LENGTH = None``.

docs/releasenotes/10.1.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Setting image mode
88
^^^^^^^^^^^^^^^^^^
99

1010
If you attempt to set the mode of an image directly, e.g.
11-
``im.mode = "RGBA"``, you will now receive an ``AttributeError``. This is
11+
``im.mode = "RGBA"``, you will now receive an :py:exc:`AttributeError`. This is
1212
not about removing existing functionality, but instead about raising an
1313
explicit error to prevent later consequences. The ``convert`` method is the
1414
correct way to change an image's mode.

docs/releasenotes/2.8.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ operations. As a result PIL was unable to open them as images, requiring a wrap
1010
``cStringIO`` or ``BytesIO``.
1111

1212
Now new functionality has been added to ``Image.open()`` by way of an ``.seek(0)`` check and
13-
catch on exception ``AttributeError`` or ``io.UnsupportedOperation``. If this is caught we
13+
catch on exception :py:exc:`AttributeError` or :py:exc:`io.UnsupportedOperation`. If this is caught we
1414
attempt to wrap the object using ``io.BytesIO`` (which will only work on buffer-file-like
1515
objects).
1616

docs/releasenotes/3.4.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Deprecation Warning when Saving JPEGs
1919

2020
JPEG images cannot contain an alpha channel. Pillow prior to 3.4.0
2121
silently drops the alpha channel. With this release Pillow will now
22-
issue a ``DeprecationWarning`` when attempting to save a ``RGBA`` mode
22+
issue a :py:exc:`DeprecationWarning` when attempting to save a ``RGBA`` mode
2323
image as a JPEG. This will become an error in Pillow 4.2.
2424

2525
New DDS Decoders

docs/releasenotes/5.3.0.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ Image size
88
^^^^^^^^^^
99

1010
If you attempt to set the size of an image directly, e.g.
11-
``im.size = (100, 100)``, you will now receive an ``AttributeError``. This is
11+
``im.size = (100, 100)``, you will now receive an :py:exc:`AttributeError`. This is
1212
not about removing existing functionality, but instead about raising an
1313
explicit error to prevent later consequences. The ``resize`` method is the
1414
correct way to change an image's size.
1515

1616
The exceptions to this are:
1717

1818
* The ICO and ICNS image formats, which use ``im.size = (100, 100)`` to select a subimage.
19-
* The TIFF image format, which now has a ``DeprecationWarning`` for this action, as direct image size setting was previously necessary to work around an issue with tile extents.
19+
* The TIFF image format, which now has a :py:exc:`DeprecationWarning` for this action,
20+
as direct image size setting was previously necessary to work around an issue with tile extents.
2021

2122

2223
API Additions

docs/releasenotes/5.4.1.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ PNG: Handle IDAT chunks after image end
1515

1616
Some PNG images have multiple IDAT chunks. In some cases, Pillow will stop
1717
reading image data before the IDAT chunks finish. A regression caused an
18-
``EOFError`` exception when previously there was none. This is now fixed, and
18+
:py:exc:`EOFError` exception when previously there was none. This is now fixed, and
1919
file reading continues in case there are subsequent text chunks.
2020

2121
PNG: MIME type
@@ -30,7 +30,7 @@ File closing
3030
^^^^^^^^^^^^
3131

3232
A regression caused an unsupported image file to report a
33-
``ValueError: seek of closed file`` exception instead of an ``OSError``. This
33+
``ValueError: seek of closed file`` exception instead of an :py:exc:`OSError`. This
3434
has been fixed by ensuring that image plugins only close their internal ``__fp``
3535
if they are not the same as ``ImageFile``'s ``fp``, allowing each to manage their own
3636
file pointers.

docs/releasenotes/6.0.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ ImageCms.CmsProfile attributes
103103
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104104

105105
Some attributes in ``ImageCms.CmsProfile`` have been deprecated since Pillow 3.2.0. From
106-
6.0.0, they issue a ``DeprecationWarning``:
106+
6.0.0, they issue a :py:exc:`DeprecationWarning`:
107107

108108
======================== ===============================
109109
Deprecated Use instead

docs/releasenotes/6.1.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ file. ``ImageFont.FreeTypeFont`` has four new methods,
5858
:py:meth:`PIL.ImageFont.FreeTypeFont.set_variation_by_name` for using named styles, and
5959
:py:meth:`PIL.ImageFont.FreeTypeFont.get_variation_axes` and
6060
:py:meth:`PIL.ImageFont.FreeTypeFont.set_variation_by_axes` for using font axes
61-
instead. An ``IOError`` will be raised if the font is not a variation font. FreeType
61+
instead. An :py:exc:`IOError` will be raised if the font is not a variation font. FreeType
6262
2.9.1 or greater is required.
6363

6464
Other Changes

docs/releasenotes/7.0.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Custom unidentified image error
8585
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8686

8787
Pillow will now throw a custom ``UnidentifiedImageError`` when an image cannot be
88-
identified. For backwards compatibility, this will inherit from ``OSError``.
88+
identified. For backwards compatibility, this will inherit from :py:exc:`OSError`.
8989

9090
New argument ``reducing_gap`` for Image.resize() and Image.thumbnail() methods
9191
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

docs/releasenotes/7.1.2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Fix another regression seeking PNG files
77
This fixes a regression introduced in 7.1.0 when adding support for APNG files.
88

99
When calling ``seek(n)`` on a regular PNG where ``n > 0``, it failed to raise an
10-
``EOFError`` as it should have done, resulting in:
10+
:py:exc:`EOFError` as it should have done, resulting in:
1111

1212
.. code-block:: pycon
1313

docs/releasenotes/7.2.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ a custom :py:class:`~PIL.ImageShow.Viewer` class.
5353
ImageFile.raise_ioerror
5454
~~~~~~~~~~~~~~~~~~~~~~~
5555

56-
``IOError`` was merged into ``OSError`` in Python 3.3. So, ``ImageFile.raise_ioerror``
56+
:py:exc:`IOError` was merged into :py:exc:`OSError` in Python 3.3. So, ``ImageFile.raise_ioerror``
5757
is now deprecated and will be removed in a future release. Use
5858
``ImageFile.raise_oserror`` instead.

docs/releasenotes/8.0.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ offset.
168168
Error for large BMP files
169169
^^^^^^^^^^^^^^^^^^^^^^^^^
170170

171-
Previously, if a BMP file was too large, an ``OSError`` would be raised. Now,
171+
Previously, if a BMP file was too large, an :py:exc:`OSError` would be raised. Now,
172172
``DecompressionBombError`` is used instead, as Pillow already uses for other formats.
173173

174174
Dark theme for docs

docs/releasenotes/8.3.1.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ Catch OSError when checking if destination is sys.stdout
2222
========================================================
2323

2424
In 8.3.0, a check to see if the destination was ``sys.stdout`` when saving an image was
25-
updated. This lead to an OSError being raised if the environment restricted access.
25+
updated. This lead to an :py:exc:`OSError` being raised if the environment restricted
26+
access.
2627

27-
The OSError is now silently caught.
28+
The :py:exc:`OSError` is now silently caught.
2829

2930
Fixed removing orientation in ImageOps.exif_transpose
3031
=====================================================
@@ -34,7 +35,7 @@ original image EXIF data was not modified, and the orientation was only removed
3435
the modified copy.
3536

3637
However, for certain images the orientation was already missing from the modified
37-
image, leading to a KeyError.
38+
image, leading to a :py:exc:`KeyError`.
3839

3940
This error has been resolved, and the copying of metadata to the modified image
4041
improved.

docs/releasenotes/9.0.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ a custom :py:class:`~PIL.ImageShow.Viewer` class.
6363
ImageFile.raise_ioerror
6464
^^^^^^^^^^^^^^^^^^^^^^^
6565

66-
``IOError`` was merged into ``OSError`` in Python 3.3. So, ``ImageFile.raise_ioerror``
66+
:py:exc:`IOError` was merged into :py:exc:`OSError` in Python 3.3. So, ``ImageFile.raise_ioerror``
6767
has been removed. Use ``ImageFile.raise_oserror`` instead.
6868

6969

docs/releasenotes/9.1.0.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ Raise an error when performing a negative crop
88
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
99

1010
Performing a negative crop on an image previously just returned a ``(0, 0)`` image. Now
11-
it will raise a ``ValueError``, to help reduce confusion if a user has unintentionally
11+
it will raise a :py:exc:`ValueError`, to help reduce confusion if a user has unintentionally
1212
provided the wrong arguments.
1313

1414
Added specific error if path coordinate type is incorrect
1515
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1616

17-
Rather than returning a ``SystemError``, passing the incorrect types of coordinates into
18-
a path will now raise a more specific ``ValueError``, with the message "incorrect
17+
Rather than returning a :py:exc:`SystemError`, passing the incorrect types of coordinates into
18+
a path will now raise a more specific :py:exc:`ValueError`, with the message "incorrect
1919
coordinate type".
2020

2121
Replace requirements.txt with extras

0 commit comments

Comments
 (0)