xml.etree.ElementTree: add support for os.PathLike for py36+ (#4097)

xml.etree.ElementTree uses open on filenames (e.g. [1]), so os.PathLike has
been supported as filenames since Python 3.6.

[1] 285ff63351/Lib/xml/etree/ElementTree.py (L584)
This commit is contained in:
Zhiming Wang
2020-05-27 16:04:12 +08:00
committed by GitHub
parent 9b4eb8c90b
commit edb7dc1171

View File

@@ -63,7 +63,11 @@ else:
# _fixtext function in the source). Client code knows best:
_str_result_type = Any
_file_or_filename = Union[str, bytes, int, IO[Any]]
if sys.version_info >= (3, 6):
from os import PathLike
_file_or_filename = Union[str, bytes, PathLike[str], int, IO[Any]]
else:
_file_or_filename = Union[str, bytes, int, IO[Any]]
if sys.version_info >= (3, 8):
class _Writeable(Protocol):