Skip to content

Commit 5796230

Browse files
committed
Fix renamed modules
A few parts of the standard library were renamed in Python 3. Import the correct name depending on whether we're running inside Python 2 or 3.
1 parent 4115a99 commit 5796230

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

utils/SwiftBuildSupport.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@
1212

1313
from __future__ import print_function
1414

15-
import ConfigParser
1615
import os
1716
import pipes
1817
import subprocess
1918
import sys
2019

20+
if sys.version_info < (3, 0):
21+
import ConfigParser
22+
else:
23+
import configparser as ConfigParser
24+
2125

2226
HOME = os.environ.get("HOME", "/")
2327

utils/gyb.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55
from __future__ import print_function
66

77
import re
8-
from cStringIO import StringIO
98
import tokenize
109
import textwrap
1110
from bisect import bisect
1211
import os
1312

13+
import sys
14+
if sys.version_info < (3, 0):
15+
from cStringIO import StringIO
16+
else:
17+
from io import StringIO
18+
1419
def getLineStarts(s):
1520
"""Return a list containing the start index of each line in s.
1621

0 commit comments

Comments
 (0)