Commit 58a5a8be authored by Christian Biesinger's avatar Christian Biesinger Committed by Commit Bot

Make install-sysroot work with Python 3

Tested: python3 src/build/linux/sysroot_scripts/install-sysroot.py --arch=x86
Bug: 941669
Change-Id: I23ad9c9e9e03df4d54e0961432a1cc11d5cce41a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1742194
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Auto-Submit: Christian Biesinger <cbiesinger@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685276}
parent b3215e7a
...@@ -29,7 +29,12 @@ import re ...@@ -29,7 +29,12 @@ import re
import shutil import shutil
import subprocess import subprocess
import sys import sys
import urllib2 try:
# For Python 3.0 and later
from urllib.request import urlopen
except ImportError:
# Fall back to Python 2's urllib2
from urllib2 import urlopen
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
...@@ -135,7 +140,7 @@ def InstallSysroot(target_platform, target_arch): ...@@ -135,7 +140,7 @@ def InstallSysroot(target_platform, target_arch):
sys.stderr.flush() sys.stderr.flush()
for _ in range(3): for _ in range(3):
try: try:
response = urllib2.urlopen(url) response = urlopen(url)
with open(tarball, "wb") as f: with open(tarball, "wb") as f:
f.write(response.read()) f.write(response.read())
break break
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment