summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorGreg Noel <GregNoel@tigris.org>2010-03-30 13:40:36 +0000
committerGreg Noel <GregNoel@tigris.org>2010-03-30 13:40:36 +0000
commit330303b697145c098a13b8b4027f13693ddd4f1c (patch)
tree462fdcb54df61499aa44203540c1c42a94ad78fd /bin
parent5d8cd8c5f516e146813964559ba8376502ddd202 (diff)
downloadscons-330303b697145c098a13b8b4027f13693ddd4f1c.tar.gz
Only one SCons file uses urllib, and only one routine from that module, so
use a simple hack to load that routine, no matter wheter it's Python 2.x or Python 3.x. Tested with Python 2.5, 2.6, and 3.0.
Diffstat (limited to 'bin')
-rw-r--r--bin/scons-test.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/bin/scons-test.py b/bin/scons-test.py
index 0089e247..2191532c 100644
--- a/bin/scons-test.py
+++ b/bin/scons-test.py
@@ -22,9 +22,18 @@ import os.path
import sys
import tempfile
import time
-import urllib
import zipfile
+try:
+ # try Python 3.x style
+ from urllib.request import urlretrieve
+except ImportError:
+ # nope, must be 2.x; this hack is equivalent
+ import imp
+ # protect import from fixer
+ urlretrieve = imp.load_module('urllib',
+ *imp.find_module('urllib')).urlretrieve
+
helpstr = """\
Usage: scons-test.py [-f zipfile] [-o outdir] [-v] [--xml] [runtest arguments]
Options:
@@ -69,7 +78,7 @@ if not os.path.exists(tempdir):
# Fetch the input file if it happens to be across a network somewhere.
# Ohmigod, does Python make this simple...
-inputfile, headers = urllib.urlretrieve(inputfile)
+inputfile, headers = urlretrieve(inputfile)
# Unzip the header file in the output directory. We use our own code
# (lifted from scons-unzip.py) to make the output subdirectory name