From d0504e6700ce48f44957a4d5891b142a60be946f Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 26 Nov 2020 12:39:11 +0100 Subject: [PATCH] Fix ValueError: invalid mode: 'rU' while trying to load binding.gyp Fixes nodejs/node-gyp#2219 File mode `U` is deprecated in Python 3 https://docs.python.org/3/library/functions.html#open https://github.com/asottile/pyupgrade#redundant-open-modes --- pylib/gyp/input.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylib/gyp/input.py b/pylib/gyp/input.py index 5504390c..90397762 100644 --- a/pylib/gyp/input.py +++ b/pylib/gyp/input.py @@ -231,7 +231,7 @@ def LoadOneBuildFile(build_file_path, data, aux_data, includes, is_target, check # 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() - if sys.platform == "zos": + if PY3 or sys.platform == "zos": # On z/OS, universal-newlines mode treats the file as an ascii file. # But since node-gyp produces ebcdic files, do not use that mode. build_file_contents = open(build_file_path, "r").read()