diff options
author | Greg Noel <GregNoel@tigris.org> | 2010-04-27 06:52:20 (GMT) |
---|---|---|
committer | Greg Noel <GregNoel@tigris.org> | 2010-04-27 06:52:20 (GMT) |
commit | 2326260437a0b6154e3fe4b9f2a7a492e88fda5c (patch) | |
tree | 37df3894b6467a3aefd074a47bf36727f08bfa16 | |
parent | 6b99d830007ea3e9c7b8f56b9eb953856c474af1 (diff) | |
download | SCons-2326260437a0b6154e3fe4b9f2a7a492e88fda5c.zip SCons-2326260437a0b6154e3fe4b9f2a7a492e88fda5c.tar.gz SCons-2326260437a0b6154e3fe4b9f2a7a492e88fda5c.tar.bz2 |
Fix test/option/profile.py to hide old-style import from fixers.
-rw-r--r-- | test/option/profile.py | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/test/option/profile.py b/test/option/profile.py index 519af73..5a4b392 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') |