Skip to content

Commit 9565b08

Browse files
guymguymrefack
authored andcommitted
Open the build file with universal-newlines mode
To make sure platform specific newlines ('\r\n' or '\r') are converted to '\n' which otherwise will fail eval(). This should handle multiple issues reported on syntax error reading binding.gyp (partial list): #979 #199 nospaceships/node-net-ping#24 nospaceships/node-net-ping#21 mathiask88/node-snap7#11 node-hid/node-hid#28 xdenser/node-firebird-libfbclient#24 PR-URL: #1053 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 3e1e0ee commit 9565b08

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

gyp/pylib/gyp/input.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,10 @@ def LoadOneBuildFile(build_file_path, data, aux_data, includes,
231231
return data[build_file_path]
232232

233233
if os.path.exists(build_file_path):
234-
build_file_contents = open(build_file_path).read()
234+
# Open the build file for read ('r') with universal-newlines mode ('U')
235+
# to make sure platform specific newlines ('\r\n' or '\r') are converted to '\n'
236+
# which otherwise will fail eval()
237+
build_file_contents = open(build_file_path, 'rU').read()
235238
else:
236239
raise GypError("%s not found (cwd: %s)" % (build_file_path, os.getcwd()))
237240

0 commit comments

Comments
 (0)