summaryrefslogtreecommitdiff
path: root/Test/pydiff.py
diff options
context:
space:
mode:
authorGravatar Dan Liew <daniel.liew@imperial.ac.uk>2014-05-28 10:35:32 +0100
committerGravatar Dan Liew <daniel.liew@imperial.ac.uk>2014-05-28 10:35:32 +0100
commitd66e2b33a03da4975720e0c85311e909eb4c3e42 (patch)
tree6958c46c0d8fcede6e84d9b2a99ffa010f20e6b9 /Test/pydiff.py
parentee399fb52a78d2efee06a8a689ab19cc25f35531 (diff)
Fix running pydiff.py under Python 2.7
Diffstat (limited to 'Test/pydiff.py')
-rw-r--r--Test/pydiff.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Test/pydiff.py b/Test/pydiff.py
index 407fe251..e42153a2 100644
--- a/Test/pydiff.py
+++ b/Test/pydiff.py
@@ -75,7 +75,8 @@ def preProcess(openFile, stripTrailingCR=False, ignoreAllSpace=False):
# newline characters because this will create a mess when outputting the
# diff. Is this the right behaviour?
deleteChars=' \t'
- translationTable = str.maketrans('','', deleteChars)
+ if sys.version_info.major >= 3:
+ translationTable = str.maketrans('','', deleteChars)
copy = [ ]
for line in original:
@@ -86,7 +87,10 @@ def preProcess(openFile, stripTrailingCR=False, ignoreAllSpace=False):
newLine = newLine[:-2] + '\n'
if ignoreAllSpace:
- newLine = newLine.translate(translationTable)
+ if sys.version_info.major >= 3:
+ newLine = newLine.translate(translationTable)
+ else:
+ newLine = newLine.translate(None, deleteChars)
copy.append(newLine)