From 4ab7b3fd1665b41af8ce0e1d6770064758e7bd09 Mon Sep 17 00:00:00 2001 From: Dustin Spicuzza Date: Sat, 2 Sep 2023 21:08:26 -0400 Subject: [PATCH] Adjust simple parse_file to accept a Path or string as filename --- cxxheaderparser/simple.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cxxheaderparser/simple.py b/cxxheaderparser/simple.py index 6d1d1c1..1670e6d 100644 --- a/cxxheaderparser/simple.py +++ b/cxxheaderparser/simple.py @@ -24,6 +24,7 @@ See below for the contents of the returned :class:`ParsedData`. """ +import os import sys import inspect import typing @@ -344,7 +345,7 @@ def parse_string( def parse_file( - filename: str, + filename: typing.Union[str, os.PathLike], encoding: typing.Optional[str] = None, *, options: typing.Optional[ParserOptions] = None, @@ -352,6 +353,7 @@ def parse_file( """ Simple function to parse a header from a file and return a data structure """ + filename = os.fsdecode(filename) if encoding is None: encoding = "utf-8-sig"