Skip to content

Commit

Permalink
[gyb] Python 2 and 3 compatible StringIO import
Browse files Browse the repository at this point in the history
The `StringIO` and `cStringIO` modules are gone in Python 3. The
recommendation is to import the `io` module on Python 3. Therefore, this
patch first attempts to import the Python 2 module, `cStringIO`, and if
that fails then attempts to import the Python 3 module, `io`.

**NOTE**: There are still other Python 3.x fixes necessary to make `gyb`
run on a Python 3.x interpreter. This is just one small incremental
patch on the way there.
  • Loading branch information
RLovelett committed Dec 31, 2015
1 parent 7700b3b commit 86650bb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion utils/gyb.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
from __future__ import print_function

import re
from cStringIO import StringIO
try:
from cStringIO import StringIO
except ImportError:
from io import StringIO
import tokenize
import textwrap
from bisect import bisect
Expand Down

0 comments on commit 86650bb

Please sign in to comment.