summaryrefslogtreecommitdiff
path: root/test/option
diff options
context:
space:
mode:
authorGreg Noel <GregNoel@tigris.org>2010-04-27 06:52:20 +0000
committerGreg Noel <GregNoel@tigris.org>2010-04-27 06:52:20 +0000
commitf187e066c4223a813dbaa327f56d29d3cf741399 (patch)
tree37df3894b6467a3aefd074a47bf36727f08bfa16 /test/option
parent0477dbbda89ad588a31adc480a7e0a2bda2073bb (diff)
downloadscons-f187e066c4223a813dbaa327f56d29d3cf741399.tar.gz
Fix test/option/profile.py to hide old-style import from fixers.
Diffstat (limited to 'test/option')
-rw-r--r--test/option/profile.py28
1 files changed, 6 insertions, 22 deletions
diff --git a/test/option/profile.py b/test/option/profile.py
index 519af73c..5a4b3927 100644
--- a/test/option/profile.py
+++ b/test/option/profile.py
@@ -25,32 +25,16 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import sys
try:
- # In Python 2.5 and before, there was no 'io' module. The 'io' module
- # in 2.6 provides a StringIO, but it only works with Unicode strings,
- # while virtually all the strings we use are normal eight-bit strings,
- # including all the strings generated by the 'profile' module. This
- # is a horrible hack that just papers over the problem without fixing
- # it, but I don't see any other way to do it. We'll keep using the old
- # StringIO module until it no longer exists, and hope that if it's not
- # there, it means that we've converted to Python 3.x where all strings
- # are Unicode.
- exec('from cStringIO import StringIO')
-except ImportError:
- # No 'cStringIO' assume new 3.x structure
- from io import StringIO
-
-try:
- import io
+ from io import StringIO as _StringIO
except (ImportError, AttributeError):
# Pre-2.6 Python has no "io" module.
- import StringIO
- StringIOClass = StringIO.StringIO
+ exec('from cStringIO import StringIO')
else:
# TODO(2.6): The 2.6 io.StringIO.write() method requires unicode strings.
# This subclass can be removed when we drop support for Python 2.6.
- class StringIOClass(io.StringIO):
+ class StringIO(_StringIO):
def write(self, s):
- super(io.StringIO, self).write(unicode(s))
+ super(_StringIO, self).write(unicode(s))
import TestSCons
@@ -74,7 +58,7 @@ test.must_contain_all_lines(test.stdout(), ['usage: scons [OPTION]'])
try:
save_stdout = sys.stdout
- sys.stdout = StringIOClass()
+ sys.stdout = StringIO()
stats = pstats.Stats(scons_prof)
stats.sort_stats('time')
@@ -95,7 +79,7 @@ test.run(arguments = "--profile %s" % scons_prof)
try:
save_stdout = sys.stdout
- sys.stdout = StringIOClass()
+ sys.stdout = StringIO()
stats = pstats.Stats(scons_prof)
stats.sort_stats('time')