aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/build_defs
diff options
context:
space:
mode:
authorGravatar David Flemström <dflemstr@users.noreply.github.com>2017-05-02 10:42:16 +0200
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2017-05-02 11:27:17 +0200
commit92ee99120a49fcdbad3adbda7c84b4d465aed335 (patch)
treec05b59bded97c7a70f68621d603404e17c8d5acd /tools/build_defs
parent62453079f729cd6247262a964010701af931620f (diff)
Make tools/build_defs/pkg/archive.py py3 compatible
Without this change, any build using python3 and involving this tool fails with: Traceback (most recent call last): File ".../bazel-out/host/bin/external/bazel_tools/tools/build_defs/pkg/build_tar.runfiles/__main__/../bazel_tools/tools/build_defs/pkg/build_tar.py", line 22, in <module> from tools.build_defs.pkg import archive File ".../bazel-out/host/bin/external/bazel_tools/tools/build_defs/pkg/build_tar.runfiles/bazel_tools/tools/build_defs/pkg/archive.py", line 17, in <module> from StringIO import StringIO ModuleNotFoundError: No module named 'StringIO' Closes #2865. PiperOrigin-RevId: 154808860
Diffstat (limited to 'tools/build_defs')
-rw-r--r--tools/build_defs/pkg/archive.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/build_defs/pkg/archive.py b/tools/build_defs/pkg/archive.py
index 9d47eb0c67..cf83aa997f 100644
--- a/tools/build_defs/pkg/archive.py
+++ b/tools/build_defs/pkg/archive.py
@@ -13,8 +13,12 @@
# limitations under the License.
"""Archive manipulation library for the Docker rules."""
+# pylint: disable=g-import-not-at-top
import os
-from StringIO import StringIO
+try:
+ from StringIO import StringIO
+except ImportError:
+ from io import StringIO
import subprocess
import tarfile