From 964371824cb44e23df93c03b5d3c5ab0a62d6c07 Mon Sep 17 00:00:00 2001 From: SpaceRacet5w2A6l0I <59487396+SpaceRacet5w2A6l0I@users.noreply.github.com> Date: Sun, 5 Jan 2020 19:07:19 +0100 Subject: [PATCH] build: avoid using CMP for BZ2File Some Python distributions do not support context manager protocol (CMP) for BZ2File. PR-URL: https://github.com/nodejs/node/pull/31198 Reviewed-By: Anna Henningsen Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Rich Trott Reviewed-By: Christian Clauss --- configure.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/configure.py b/configure.py index bc6bff224b6515..682feb44e459a3 100755 --- a/configure.py +++ b/configure.py @@ -1540,8 +1540,11 @@ def write_config(data, name): os.mkdir(icu_tmp_path) icu_data_path = os.path.join(icu_tmp_path, icu_data_file_l) with open(icu_data_path, 'wb') as outf: - with bz2.BZ2File(compressed_data, 'rb') as inf: - shutil.copyfileobj(inf, outf) + inf = bz2.BZ2File(compressed_data, 'rb') + try: + shutil.copyfileobj(inf, outf) + finally: + inf.close() # Now, proceed.. # relative to dep..