mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +03:00 
			
		
		
		
	Merge pull request #144 from radarhere/use-ptr
Use CapsuleType hint in Python >= 3.13
This commit is contained in:
		
						commit
						bd14915364
					
				| 
						 | 
					@ -224,12 +224,7 @@ if TYPE_CHECKING:
 | 
				
			||||||
    from IPython.lib.pretty import PrettyPrinter
 | 
					    from IPython.lib.pretty import PrettyPrinter
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    from . import ImageFile, ImageFilter, ImagePalette, ImageQt, TiffImagePlugin
 | 
					    from . import ImageFile, ImageFilter, ImagePalette, ImageQt, TiffImagePlugin
 | 
				
			||||||
    from ._typing import NumpyArray, StrOrBytesPath, TypeGuard
 | 
					    from ._typing import CapsuleType, NumpyArray, StrOrBytesPath, TypeGuard
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if sys.version_info >= (3, 13):
 | 
					 | 
				
			||||||
        from types import CapsuleType
 | 
					 | 
				
			||||||
    else:
 | 
					 | 
				
			||||||
        CapsuleType = object
 | 
					 | 
				
			||||||
ID: list[str] = []
 | 
					ID: list[str] = []
 | 
				
			||||||
OPEN: dict[
 | 
					OPEN: dict[
 | 
				
			||||||
    str,
 | 
					    str,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,6 +32,9 @@ from typing import TYPE_CHECKING, Any, cast
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from . import Image, ImageFile
 | 
					from . import Image, ImageFile
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if TYPE_CHECKING:
 | 
				
			||||||
 | 
					    from ._typing import CapsuleType
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# --------------------------------------------------------------------
 | 
					# --------------------------------------------------------------------
 | 
				
			||||||
# Check for Tkinter interface hooks
 | 
					# Check for Tkinter interface hooks
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,7 +51,7 @@ def _get_image_from_kw(kw: dict[str, Any]) -> ImageFile.ImageFile | None:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def _pyimagingtkcall(
 | 
					def _pyimagingtkcall(
 | 
				
			||||||
    command: str, photo: PhotoImage | tkinter.PhotoImage, ptr: object
 | 
					    command: str, photo: PhotoImage | tkinter.PhotoImage, ptr: CapsuleType
 | 
				
			||||||
) -> None:
 | 
					) -> None:
 | 
				
			||||||
    tk = photo.tk
 | 
					    tk = photo.tk
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,6 +15,11 @@ if TYPE_CHECKING:
 | 
				
			||||||
    except (ImportError, AttributeError):
 | 
					    except (ImportError, AttributeError):
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if sys.version_info >= (3, 13):
 | 
				
			||||||
 | 
					    from types import CapsuleType
 | 
				
			||||||
 | 
					else:
 | 
				
			||||||
 | 
					    CapsuleType = object
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if sys.version_info >= (3, 12):
 | 
					if sys.version_info >= (3, 12):
 | 
				
			||||||
    from collections.abc import Buffer
 | 
					    from collections.abc import Buffer
 | 
				
			||||||
else:
 | 
					else:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user