diff --git a/Tests/test_image.py b/Tests/test_image.py index 2d661a903..6717cbc5a 100644 --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -813,35 +813,6 @@ class TestImage: with pytest.warns(DeprecationWarning): assert Image.CONTAINER == 2 - @pytest.mark.parametrize( - "test_module", - [PIL, Image], - ) - def test_pillow_version(self, test_module): - with pytest.warns(DeprecationWarning): - assert test_module.PILLOW_VERSION == PIL.__version__ - - with pytest.warns(DeprecationWarning): - str(test_module.PILLOW_VERSION) - - with pytest.warns(DeprecationWarning): - assert int(test_module.PILLOW_VERSION[0]) >= 7 - - with pytest.warns(DeprecationWarning): - assert test_module.PILLOW_VERSION < "9.9.0" - - with pytest.warns(DeprecationWarning): - assert test_module.PILLOW_VERSION <= "9.9.0" - - with pytest.warns(DeprecationWarning): - assert test_module.PILLOW_VERSION != "7.0.0" - - with pytest.warns(DeprecationWarning): - assert test_module.PILLOW_VERSION >= "7.0.0" - - with pytest.warns(DeprecationWarning): - assert test_module.PILLOW_VERSION > "7.0.0" - @pytest.mark.parametrize( "path", [ diff --git a/docs/deprecations.rst b/docs/deprecations.rst index 45720ccc0..812ed3194 100644 --- a/docs/deprecations.rst +++ b/docs/deprecations.rst @@ -51,17 +51,6 @@ ImageFile.raise_ioerror So, ``ImageFile.raise_ioerror`` will be removed in Pillow 9.0.0 (2022-01-02). Use ``ImageFile.raise_oserror`` instead. -PILLOW_VERSION constant -~~~~~~~~~~~~~~~~~~~~~~~ - -.. deprecated:: 5.2.0 - -``PILLOW_VERSION`` will be removed in Pillow 9.0.0 (2022-01-02). -Use ``__version__`` instead. - -It was initially removed in Pillow 7.0.0, but brought back in 7.1.0 to give projects -more time to upgrade. - Tk/Tcl 8.4 ~~~~~~~~~~ @@ -109,6 +98,17 @@ Removed features Deprecated features are only removed in major releases after an appropriate period of deprecation has passed. +PILLOW_VERSION constant +~~~~~~~~~~~~~~~~~~~~~~~ + +.. deprecated:: 5.2.0 +.. versionremoved:: 9.0.0 + +Use ``__version__`` instead. + +It was initially removed in Pillow 7.0.0, but temporarily brought back in 7.1.0 +to give projects more time to upgrade. + im.offset ~~~~~~~~~ diff --git a/docs/releasenotes/9.0.0.rst b/docs/releasenotes/9.0.0.rst new file mode 100644 index 000000000..e10287dca --- /dev/null +++ b/docs/releasenotes/9.0.0.rst @@ -0,0 +1,10 @@ +9.0.0 +----- + +Backwards Incompatible Changes +============================== + +PILLOW_VERSION constant +^^^^^^^^^^^^^^^^^^^^^^^ + +``PILLOW_VERSION`` has been removed. Use ``__version__`` instead. diff --git a/docs/releasenotes/index.rst b/docs/releasenotes/index.rst index f42ea72e8..8d1ad7837 100644 --- a/docs/releasenotes/index.rst +++ b/docs/releasenotes/index.rst @@ -14,6 +14,7 @@ expected to be backported to earlier versions. .. toctree:: :maxdepth: 2 + 9.0.0 8.4.0 8.3.2 8.3.1 diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 7dd5b35bd..439b1c932 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -45,45 +45,28 @@ except ImportError: ElementTree = None # VERSION was removed in Pillow 6.0.0. -# PILLOW_VERSION is deprecated and will be removed in a future release. +# PILLOW_VERSION was removed in Pillow 9.0.0. # Use __version__ instead. -from . import ( - ImageMode, - TiffTags, - UnidentifiedImageError, - __version__, - _plugins, - _raise_version_warning, -) +from . import ImageMode, TiffTags, UnidentifiedImageError, __version__, _plugins from ._binary import i32le from ._util import deferred_error, isPath if sys.version_info >= (3, 7): def __getattr__(name): - if name == "PILLOW_VERSION": - _raise_version_warning() - return __version__ - else: - categories = {"NORMAL": 0, "SEQUENCE": 1, "CONTAINER": 2} - if name in categories: - warnings.warn( - "Image categories are deprecated and will be removed in Pillow 10 " - "(2023-01-02). Use is_animated instead.", - DeprecationWarning, - stacklevel=2, - ) - return categories[name] + categories = {"NORMAL": 0, "SEQUENCE": 1, "CONTAINER": 2} + if name in categories: + warnings.warn( + "Image categories are deprecated and will be removed in Pillow 10 " + "(2023-01-02). Use is_animated instead.", + DeprecationWarning, + stacklevel=2, + ) + return categories[name] raise AttributeError(f"module '{__name__}' has no attribute '{name}'") else: - - from . import PILLOW_VERSION - - # Silence warning - assert PILLOW_VERSION - # categories NORMAL = 0 SEQUENCE = 1 diff --git a/src/PIL/__init__.py b/src/PIL/__init__.py index 890ae44f5..dbde52a1b 100644 --- a/src/PIL/__init__.py +++ b/src/PIL/__init__.py @@ -19,66 +19,9 @@ import warnings from . import _version # VERSION was removed in Pillow 6.0.0. -__version__ = _version.__version__ - - -# PILLOW_VERSION is deprecated and will be removed in a future release. +# PILLOW_VERSION was removed in Pillow 9.0.0. # Use __version__ instead. -def _raise_version_warning(): - warnings.warn( - "PILLOW_VERSION is deprecated and will be removed in Pillow 9 (2022-01-02). " - "Use __version__ instead.", - DeprecationWarning, - stacklevel=3, - ) - - -if sys.version_info >= (3, 7): - - def __getattr__(name): - if name == "PILLOW_VERSION": - _raise_version_warning() - return __version__ - raise AttributeError(f"module '{__name__}' has no attribute '{name}'") - - -else: - - class _Deprecated_Version(str): - def __str__(self): - _raise_version_warning() - return super().__str__() - - def __getitem__(self, key): - _raise_version_warning() - return super().__getitem__(key) - - def __eq__(self, other): - _raise_version_warning() - return super().__eq__(other) - - def __ne__(self, other): - _raise_version_warning() - return super().__ne__(other) - - def __gt__(self, other): - _raise_version_warning() - return super().__gt__(other) - - def __lt__(self, other): - _raise_version_warning() - return super().__lt__(other) - - def __ge__(self, other): - _raise_version_warning() - return super().__gt__(other) - - def __le__(self, other): - _raise_version_warning() - return super().__lt__(other) - - PILLOW_VERSION = _Deprecated_Version(__version__) - +__version__ = _version.__version__ del _version