diff --git a/src/ctypesgen/printer_json.py b/src/ctypesgen/printer_json.py index 7f1253a..322e814 100755 --- a/src/ctypesgen/printer_json.py +++ b/src/ctypesgen/printer_json.py @@ -1,4 +1,5 @@ import json +from pathlib import Path from ctypesgen.ctypedescs import CtypesBitfield @@ -48,6 +49,7 @@ def __init__(self, outpath, options, data, argv): res = [] for kind, desc in data: + desc.src = (str(Path(desc.src[0]).as_posix()), *desc.src[1:]) item = method_table[kind](desc) if item: res.append(item) with outpath.open("w", encoding="utf-8") as fh: diff --git a/src/ctypesgen/printer_python.py b/src/ctypesgen/printer_python.py index c00410d..6b22063 100755 --- a/src/ctypesgen/printer_python.py +++ b/src/ctypesgen/printer_python.py @@ -79,7 +79,7 @@ def __init__(self, outpath, opts, data, argv): @classmethod def _txtpath(cls, s): # Returns a path string suitable for embedding into the output, with private paths stripped - s = str(s) + s = str( Path(s).as_posix() ) for p, x in cls.PRIVATE_PATHS_TABLE: if s.startswith(p): return x + s[len(p):] diff --git a/tests/json_expects.py b/tests/json_expects.py index 8037510..714a1da 100644 --- a/tests/json_expects.py +++ b/tests/json_expects.py @@ -49,10 +49,7 @@ def _replace_anon_tag(self, json, tag, new_tag): if value == tag: json[key] = new_tag elif key == "src" and isinstance(value, list) and value: - # for whatever reason, on windows ctypesgen's json output contains double slashes in paths, whereas the expectation contains only single slashes, so normalize the output - if sys.platform == "win32": - value[0] = value[0].replace("\\\\", "\\") - # # ignore the line number so changing headers does not cause erroneous test fails + # ignore the line number so changing headers does not cause erroneous test fails value[1] = None else: self._replace_anon_tag(value, tag, new_tag)