Skip to content

Commit 27c3a7b

Browse files
authored
Merge pull request #33185 from compnerd/normally
test: normalize the path before opening
2 parents ea81e26 + 7779fb3 commit 27c3a7b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

utils/gyb.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,9 @@ class ParseContext(object):
400400
def __init__(self, filename, template=None):
401401
self.filename = os.path.abspath(filename)
402402
if sys.platform == 'win32':
403-
self.filename = self.filename.replace('\\', '/')
403+
self.filename = '/'.join(self.filename.split(os.sep))
404404
if template is None:
405-
with io.open(filename, encoding='utf-8') as f:
405+
with io.open(os.path.normpath(filename), encoding='utf-8') as f:
406406
self.template = f.read()
407407
else:
408408
self.template = template
@@ -1251,7 +1251,7 @@ def succ(a):
12511251
if args.file == '-':
12521252
ast = parse_template('stdin', sys.stdin.read())
12531253
else:
1254-
with io.open(args.file, 'r', encoding='utf-8') as f:
1254+
with io.open(os.path.normpath(args.file), 'r', encoding='utf-8') as f:
12551255
ast = parse_template(args.file, f.read())
12561256
if args.dump:
12571257
print(ast)

0 commit comments

Comments
 (0)