mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[gyb] Remove Python 2 (#42046)
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
#!/usr/bin/env python2.7
|
||||
#!/usr/bin/env python3
|
||||
import gyb
|
||||
gyb.main()
|
||||
|
||||
19
utils/gyb.py
19
utils/gyb.py
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# GYB: Generate Your Boilerplate (improved names welcome; at least
|
||||
# this one's short). See -h output for instructions
|
||||
|
||||
@@ -11,18 +11,7 @@ import sys
|
||||
import textwrap
|
||||
import tokenize
|
||||
from bisect import bisect
|
||||
|
||||
|
||||
try:
|
||||
from StringIO import StringIO
|
||||
except ImportError:
|
||||
from io import StringIO
|
||||
|
||||
|
||||
try:
|
||||
basestring
|
||||
except NameError:
|
||||
basestring = str
|
||||
from io import StringIO
|
||||
|
||||
|
||||
def get_line_starts(s):
|
||||
@@ -732,7 +721,7 @@ class Code(ASTNode):
|
||||
# If we got a result, the code was an expression, so append
|
||||
# its value
|
||||
if result is not None \
|
||||
or (isinstance(result, basestring) and result != ''):
|
||||
or (isinstance(result, str) and result != ''):
|
||||
from numbers import Number, Integral
|
||||
result_string = None
|
||||
if isinstance(result, Number) and not isinstance(result, Integral):
|
||||
@@ -740,7 +729,7 @@ class Code(ASTNode):
|
||||
elif isinstance(result, Integral) or isinstance(result, list):
|
||||
result_string = str(result)
|
||||
else:
|
||||
result_string = StringIO(result).read()
|
||||
result_string = result
|
||||
context.append_text(
|
||||
result_string, self.filename, self.start_line_number)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user