From a20a8f48f7b9b8243dd6db03e3fb2cd058208c03 Mon Sep 17 00:00:00 2001
From: Christian Clauss <cclauss@me.com>
Date: Tue, 3 Sep 2019 09:34:54 +0200
Subject: [PATCH] gyp: make StringIO work in ninja.py
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Allow both Python 2 and 3 to access StringIO.

This fixes `./configure --ninja`, which was broken by
https://github.com/nodejs/node/pull/29371.

See: https://github.com/nodejs/node/pull/29371#issuecomment-527331969

PR-URL: https://github.com/nodejs/node/pull/29414
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
---
 tools/gyp/pylib/gyp/generator/ninja.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/gyp/pylib/gyp/generator/ninja.py b/tools/gyp/pylib/gyp/generator/ninja.py
index 7d1d3b7b30b5f1..e66979ddbb5273 100644
--- a/tools/gyp/pylib/gyp/generator/ninja.py
+++ b/tools/gyp/pylib/gyp/generator/ninja.py
@@ -20,7 +20,10 @@
 import gyp.msvs_emulation
 import gyp.MSVSUtil as MSVSUtil
 import gyp.xcode_emulation
-from io import StringIO
+try:
+  from cStringIO import StringIO
+except ImportError:
+  from io import StringIO
 
 from gyp.common import GetEnvironFallback
 import gyp.ninja_syntax as ninja_syntax