mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +03:00 
			
		
		
		
	deprecate EpsImagePlugin.PSFile
This commit is contained in:
		
							parent
							
								
									be9aea35a8
								
							
						
					
					
						commit
						bd0fac80c4
					
				| 
						 | 
				
			
			@ -311,6 +311,7 @@ def test_read_binary_preview():
 | 
			
		|||
        pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
 | 
			
		||||
def test_readline_psfile(tmp_path):
 | 
			
		||||
    # check all the freaking line endings possible from the spec
 | 
			
		||||
    # test_string = u'something\r\nelse\n\rbaz\rbif\n'
 | 
			
		||||
| 
						 | 
				
			
			@ -346,6 +347,11 @@ def test_readline_psfile(tmp_path):
 | 
			
		|||
        _test_readline_file_psfile(s, ending)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_psfile_deprecation():
 | 
			
		||||
    with pytest.warns(DeprecationWarning):
 | 
			
		||||
        EpsImagePlugin.PSFile(None)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@pytest.mark.parametrize("prefix", (b"", simple_binary_header))
 | 
			
		||||
@pytest.mark.parametrize(
 | 
			
		||||
    "line_ending",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -80,6 +80,16 @@ A number of constants have been deprecated and will be removed in Pillow 10.0.0
 | 
			
		|||
    was reversed in Pillow 9.4.0 and those constants will now remain available.
 | 
			
		||||
    See :ref:`restored-image-constants`
 | 
			
		||||
 | 
			
		||||
PSFile
 | 
			
		||||
~~~~~~
 | 
			
		||||
 | 
			
		||||
.. deprecated:: 9.4.0
 | 
			
		||||
 | 
			
		||||
The :py:class:`~PIL.EpsImagePlugin.PSFile` class has been deprecated and will
 | 
			
		||||
be removed in Pillow 11 (2024-10-15). This class was only made as a helper to
 | 
			
		||||
be used internally, so there is no replacement. If you need this functionality
 | 
			
		||||
though, it is a very short class that can easily be recreated in your own code.
 | 
			
		||||
 | 
			
		||||
=====================================================  ============================================================
 | 
			
		||||
Deprecated                                             Use instead
 | 
			
		||||
=====================================================  ============================================================
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,17 @@
 | 
			
		|||
9.4.0
 | 
			
		||||
-----
 | 
			
		||||
 | 
			
		||||
Deprecations
 | 
			
		||||
============
 | 
			
		||||
 | 
			
		||||
PSFile
 | 
			
		||||
^^^^^^
 | 
			
		||||
 | 
			
		||||
The :py:class:`~PIL.EpsImagePlugin.PSFile` class has been deprecated and will
 | 
			
		||||
be removed in Pillow 11 (2024-10-15). This class was only made as a helper to
 | 
			
		||||
be used internally, so there is no replacement. If you need this functionality
 | 
			
		||||
though, it is a very short class that can easily be recreated in your own code.
 | 
			
		||||
 | 
			
		||||
API Additions
 | 
			
		||||
=============
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,6 +29,7 @@ import tempfile
 | 
			
		|||
 | 
			
		||||
from . import Image, ImageFile
 | 
			
		||||
from ._binary import i32le as i32
 | 
			
		||||
from ._deprecate import deprecate
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
# --------------------------------------------------------------------
 | 
			
		||||
| 
						 | 
				
			
			@ -166,6 +167,11 @@ class PSFile:
 | 
			
		|||
    """
 | 
			
		||||
 | 
			
		||||
    def __init__(self, fp):
 | 
			
		||||
        deprecate(
 | 
			
		||||
            "PSFile",
 | 
			
		||||
            11,
 | 
			
		||||
            action="If you need the functionality of this class you will need to implement it yourself.",
 | 
			
		||||
        )
 | 
			
		||||
        self.fp = fp
 | 
			
		||||
        self.char = None
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,8 +47,10 @@ def deprecate(
 | 
			
		|||
        raise RuntimeError(msg)
 | 
			
		||||
    elif when == 10:
 | 
			
		||||
        removed = "Pillow 10 (2023-07-01)"
 | 
			
		||||
    elif when == 11:
 | 
			
		||||
        removed = "Pillow 11 (2024-10-15)"
 | 
			
		||||
    else:
 | 
			
		||||
        msg = f"Unknown removal version, update {__name__}?"
 | 
			
		||||
        msg = f"Unknown removal version: {when}. Update {__name__}?"
 | 
			
		||||
        raise ValueError(msg)
 | 
			
		||||
 | 
			
		||||
    if replacement and action:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user