summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Forstall <Bruce_Forstall@msn.com>2018-12-13 14:53:31 -0800
committerBruce Forstall <Bruce_Forstall@msn.com>2018-12-13 14:53:31 -0800
commitbba070bf2f7d975e9b0c6b45a601e0a43b6a6b38 (patch)
treefaf917ae31e3989fa65cf2fb8a2750d4bc360ce6
parent4d7f7112efaf54a9634abf2f3a8fecc254301c85 (diff)
downloadcoreclr-bba070bf2f7d975e9b0c6b45a601e0a43b6a6b38.tar.gz
coreclr-bba070bf2f7d975e9b0c6b45a601e0a43b6a6b38.tar.bz2
coreclr-bba070bf2f7d975e9b0c6b45a601e0a43b6a6b38.zip
Fix Python 3 issues
Fixes #21433
-rw-r--r--tests/scripts/format.py25
-rw-r--r--tests/scripts/run-corefx-tests.py4
-rw-r--r--tests/scripts/run-pmi-diffs.py19
3 files changed, 27 insertions, 21 deletions
diff --git a/tests/scripts/format.py b/tests/scripts/format.py
index 658e7f93e5..b622cf4625 100644
--- a/tests/scripts/format.py
+++ b/tests/scripts/format.py
@@ -12,21 +12,26 @@
################################################################################
-import urllib
import argparse
import os
import sys
import tarfile
import zipfile
import subprocess
-import urllib2
import shutil
+# Version specific imports
+
+if sys.version_info.major < 3:
+ import urllib
+else:
+ import urllib.request
+
def expandPath(path):
return os.path.abspath(os.path.expanduser(path))
def del_rw(action, name, exc):
- os.chmod(name, 0651)
+ os.chmod(name, 0o651)
os.remove(name)
def main(argv):
@@ -42,13 +47,13 @@ def main(argv):
args, unknown = parser.parse_known_args(argv)
if unknown:
- print('Ignorning argument(s): ', ','.join(unknown))
+ print('Ignoring argument(s): ', ','.join(unknown))
if args.coreclr is None:
print('Specify --coreclr')
return -1
if args.os is None:
- print('Specifiy --os')
+ print('Specify --os')
return -1
if args.arch is None:
print('Specify --arch')
@@ -97,10 +102,8 @@ def main(argv):
print('Unknown os ', os)
return -1
- response = urllib2.urlopen(dotnetcliUrl)
- request_url = response.geturl()
- testfile = urllib.URLopener()
- testfile.retrieve(request_url, dotnetcliFilename)
+ urlretrieve = urllib.urlretrieve if sys.version_info.major < 3 else urllib.request.urlretrieve
+ urlretrieve(dotnetcliUrl, dotnetcliFilename)
if not os.path.isfile(dotnetcliFilename):
print("Did not download .Net CLI!")
@@ -145,7 +148,7 @@ def main(argv):
bootstrapUrl = "https://raw.githubusercontent.com/dotnet/jitutils/master/" + bootstrapFilename
bootstrapPath = os.path.join(coreclr, bootstrapFilename)
- testfile.retrieve(bootstrapUrl, bootstrapPath)
+ urlretrieve(bootstrapUrl, bootstrapPath)
if not os.path.isfile(bootstrapPath):
print("Did not download bootstrap!")
@@ -155,7 +158,7 @@ def main(argv):
if platform == 'Linux' or platform == 'OSX':
print("Making bootstrap executable")
- os.chmod(bootstrapPath, 0751)
+ os.chmod(bootstrapPath, 0o751)
print(bootstrapPath)
diff --git a/tests/scripts/run-corefx-tests.py b/tests/scripts/run-corefx-tests.py
index 57b21f3d52..76adfe2d54 100644
--- a/tests/scripts/run-corefx-tests.py
+++ b/tests/scripts/run-corefx-tests.py
@@ -50,7 +50,7 @@ Is_windows = (os.name == 'nt')
##########################################################################
def del_rw(action, name, exc):
- os.chmod(name, 0651)
+ os.chmod(name, 0o651)
os.remove(name)
##########################################################################
@@ -181,7 +181,7 @@ def log(message):
message (str): message to be printed
"""
- print '[%s]: %s' % (sys.argv[0], message)
+ print('[%s]: %s' % (sys.argv[0], message))
def copy_files(source_dir, target_dir):
""" Copy any files in the source_dir to the target_dir.
diff --git a/tests/scripts/run-pmi-diffs.py b/tests/scripts/run-pmi-diffs.py
index acf15fcc40..2be7b8ebbc 100644
--- a/tests/scripts/run-pmi-diffs.py
+++ b/tests/scripts/run-pmi-diffs.py
@@ -26,12 +26,17 @@ import os
import re
import shutil
import subprocess
-import urllib
-import urllib2
import sys
import tarfile
import zipfile
+# Version specific imports
+
+if sys.version_info.major < 3:
+ import urllib
+else:
+ import urllib.request
+
##########################################################################
# Globals
##########################################################################
@@ -67,7 +72,7 @@ Clr_os = 'Windows_NT' if Is_windows else Unix_name_map[os.uname()[0]]
##########################################################################
def del_rw(action, name, exc):
- os.chmod(name, 0651)
+ os.chmod(name, 0o651)
os.remove(name)
##########################################################################
@@ -221,7 +226,7 @@ def log(message):
message (str): message to be printed
"""
- print '[%s]: %s' % (sys.argv[0], message)
+ print('[%s]: %s' % (sys.argv[0], message))
def copy_files(source_dir, target_dir):
""" Copy any files in the source_dir to the target_dir.
@@ -453,10 +458,8 @@ def do_pmi_diffs():
log('Downloading: %s => %s' % (dotnetcliUrl, dotnetcliFilename))
if not testing:
- response = urllib2.urlopen(dotnetcliUrl)
- request_url = response.geturl()
- testfile = urllib.URLopener()
- testfile.retrieve(request_url, dotnetcliFilename)
+ urlretrieve = urllib.urlretrieve if sys.version_info.major < 3 else urllib.request.urlretrieve
+ urlretrieve(dotnetcliUrl, dotnetcliFilename)
if not os.path.isfile(dotnetcliFilename):
log('ERROR: Did not download .Net CLI')