Skip to content

Commit 5459eca

Browse files
cclaussjoaocgreis
authored andcommitted
build: import StringIO on Python 2 and Python 3
This change supports access to StringIO on both Python 2 and Python 3 PR-URL: #1836 Reviewed-By: Rod Vagg <[email protected]> Reviewed-By: João Reis <[email protected]>
1 parent 4ef83ed commit 5459eca

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

gyp/pylib/gyp/MSVSSettings_test.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@
66

77
"""Unit tests for the MSVSSettings.py file."""
88

9-
import StringIO
9+
try:
10+
from cStringIO import StringIO
11+
except ImportError:
12+
from io import StringIO
13+
1014
import unittest
1115
import gyp.MSVSSettings as MSVSSettings
1216

1317

1418
class TestSequenceFunctions(unittest.TestCase):
1519

1620
def setUp(self):
17-
self.stderr = StringIO.StringIO()
21+
self.stderr = StringIO()
1822

1923
def _ExpectedWarnings(self, expected):
2024
"""Compares recorded lines to expected warnings."""

gyp/pylib/gyp/easy_xml_test.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88

99
import gyp.easy_xml as easy_xml
1010
import unittest
11-
import StringIO
11+
try:
12+
from cStringIO import StringIO
13+
except ImportError:
14+
from io import StringIO
1215

1316

1417
class TestSequenceFunctions(unittest.TestCase):
1518

1619
def setUp(self):
17-
self.stderr = StringIO.StringIO()
20+
self.stderr = StringIO()
1821

1922
def test_EasyXml_simple(self):
2023
self.assertEqual(

gyp/pylib/gyp/generator/msvs_test.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77

88
import gyp.generator.msvs as msvs
99
import unittest
10-
import StringIO
10+
try:
11+
from cStringIO import StringIO
12+
except ImportError:
13+
from io import StringIO
1114

1215

1316
class TestSequenceFunctions(unittest.TestCase):
1417

1518
def setUp(self):
16-
self.stderr = StringIO.StringIO()
19+
self.stderr = StringIO()
1720

1821
def test_GetLibraries(self):
1922
self.assertEqual(

gyp/pylib/gyp/generator/ninja.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
import gyp.msvs_emulation
2020
import gyp.MSVSUtil as MSVSUtil
2121
import gyp.xcode_emulation
22-
from cStringIO import StringIO
22+
try:
23+
from cStringIO import StringIO
24+
except ImportError:
25+
from io import StringIO
2326

2427
from gyp.common import GetEnvironFallback
2528
import gyp.ninja_syntax as ninja_syntax

gyp/pylib/gyp/generator/ninja_test.py

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import gyp.generator.ninja as ninja
1010
import unittest
11-
import StringIO
1211
import sys
1312
import TestCommon
1413

0 commit comments

Comments
 (0)