bpo-31658: Make xml.sax.parse accepting Path objects (GH-8564)

This commit is contained in:
Mickaël Schoentgen 2019-04-14 09:16:54 +00:00 committed by Stefan Behnel
parent e9927e1820
commit 929b704738
4 changed files with 21 additions and 2 deletions

View file

@ -339,6 +339,8 @@ def prepare_input_source(source, base=""):
"""This function takes an InputSource and an optional base URL and
returns a fully resolved InputSource object ready for reading."""
if isinstance(source, os.PathLike):
source = os.fspath(source)
if isinstance(source, str):
source = xmlreader.InputSource(source)
elif hasattr(source, "read"):