Skip to content

Commit

Permalink
Open the build file with universal-newlines mode
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
guymguym authored and bnoordhuis committed Nov 16, 2016
1 parent 37ae7be commit 05c4494
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gyp/pylib/gyp/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ def LoadOneBuildFile(build_file_path, data, aux_data, includes,
return data[build_file_path]

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

Expand Down

0 comments on commit 05c4494

Please sign in to comment.