bpo-31658: Make xml.sax.parse accepting Path objects (GH-8564)
diff --git a/Lib/xml/sax/saxutils.py b/Lib/xml/sax/saxutils.py
index b4fc2da..c1612ea 100644
--- a/Lib/xml/sax/saxutils.py
+++ b/Lib/xml/sax/saxutils.py
@@ -339,6 +339,8 @@
"""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"):