Issue #28228: imghdr now supports pathlib

This commit is contained in:
Berker Peksag 2016-10-01 05:01:54 +03:00
parent 6c63f197df
commit ef223a19f7
4 changed files with 15 additions and 1 deletions

View file

@ -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: