diff options
author | Greg Noel <GregNoel@tigris.org> | 2010-03-30 13:40:36 (GMT) |
---|---|---|
committer | Greg Noel <GregNoel@tigris.org> | 2010-03-30 13:40:36 (GMT) |
commit | 1c54f078cfd4a00cd2d231adeea1ac3a8636e259 (patch) | |
tree | 462fdcb54df61499aa44203540c1c42a94ad78fd /bin | |
parent | 53ea2c21cf5a564a29580895c13c13a2511258a8 (diff) | |
download | SCons-1c54f078cfd4a00cd2d231adeea1ac3a8636e259.zip SCons-1c54f078cfd4a00cd2d231adeea1ac3a8636e259.tar.gz SCons-1c54f078cfd4a00cd2d231adeea1ac3a8636e259.tar.bz2 |
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.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/bin/scons-test.py b/bin/scons-test.py index 0089e24..2191532 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 |