mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
Issue #28228: imghdr now supports pathlib
This commit is contained in:
parent
6c63f197df
commit
ef223a19f7
4 changed files with 15 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
|||
"""Recognize image file formats based on their first few bytes."""
|
||||
|
||||
from os import PathLike
|
||||
|
||||
__all__ = ["what"]
|
||||
|
||||
#-------------------------#
|
||||
|
@ -10,7 +12,7 @@ def what(file, h=None):
|
|||
f = None
|
||||
try:
|
||||
if h is None:
|
||||
if isinstance(file, str):
|
||||
if isinstance(file, (str, PathLike)):
|
||||
f = open(file, 'rb')
|
||||
h = f.read(32)
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue