diff --git a/autopxd/__init__.py b/autopxd/__init__.py index 20709bf..79e502d 100644 --- a/autopxd/__init__.py +++ b/autopxd/__init__.py @@ -303,9 +303,11 @@ def lines(self): def preprocess(code, extra_cpp_args=[]): - proc = subprocess.Popen([ - 'cpp', '-nostdinc', '-D__attribute__(x)=', '-I', BUILTIN_HEADERS_DIR, - ] + extra_cpp_args + ['-'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) + proc = subprocess.Popen( + ['cpp', '-nostdinc', '-D__attribute__(x)=', + '-I', BUILTIN_HEADERS_DIR] + + extra_cpp_args + ['-'], + stdin=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True) result = [] result.append(proc.communicate(input=code.encode('utf-8'))[0]) while proc.poll() is None: @@ -328,7 +330,7 @@ def parse(code, extra_cpp_args=[]): def translate(code, hdrname, extra_cpp_args=[]): - extra_incdir = os.path.dirname(hdrname) + extra_incdir = os.path.normpath(os.path.dirname(hdrname)) p = AutoPxd(hdrname) p.visit(parse(code, extra_cpp_args=['-I', extra_incdir])) return str(p)