Skip to content

Commit 9129ab8

Browse files
committed
[gyb] Remove Python 2
1 parent 069653d commit 9129ab8

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

utils/gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
#!/usr/bin/env python2.7
1+
#!/usr/bin/env python3
22
import gyb
33
gyb.main()

utils/gyb.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# GYB: Generate Your Boilerplate (improved names welcome; at least
33
# this one's short). See -h output for instructions
44

@@ -11,18 +11,7 @@
1111
import textwrap
1212
import tokenize
1313
from bisect import bisect
14-
15-
16-
try:
17-
from StringIO import StringIO
18-
except ImportError:
19-
from io import StringIO
20-
21-
22-
try:
23-
basestring
24-
except NameError:
25-
basestring = str
14+
from io import StringIO
2615

2716

2817
def get_line_starts(s):
@@ -732,15 +721,15 @@ def execute(self, context):
732721
# If we got a result, the code was an expression, so append
733722
# its value
734723
if result is not None \
735-
or (isinstance(result, basestring) and result != ''):
724+
or (isinstance(result, str) and result != ''):
736725
from numbers import Number, Integral
737726
result_string = None
738727
if isinstance(result, Number) and not isinstance(result, Integral):
739728
result_string = repr(result)
740729
elif isinstance(result, Integral) or isinstance(result, list):
741730
result_string = str(result)
742731
else:
743-
result_string = StringIO(result).read()
732+
result_string = result
744733
context.append_text(
745734
result_string, self.filename, self.start_line_number)
746735

0 commit comments

Comments
 (0)