summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas.sandberg@arm.com>2016-04-18 10:31:38 +0100
committerAndreas Sandberg <andreas.sandberg@arm.com>2016-04-18 10:31:38 +0100
commitf81951815877874b212b1963e76af3596855c337 (patch)
tree2ca3948b0a4d4a40e0281b9eb13f28abe11ff1cd
parent39e10ced035a7e1f53673fc998741f8b6067135d (diff)
downloadgem5-f81951815877874b212b1963e76af3596855c337.tar.xz
style: Fix Python 2.6 compatibility
The style checker code needs to disable autojunk when diffing source files using Python's difflib. Support for this was only introduced in Python 2.7, which leads to a TypeError exception on older Python version. This changeset adds a fallback mechanism for old Python versions.
-rw-r--r--util/style/verifiers.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/util/style/verifiers.py b/util/style/verifiers.py
index 7650d3071..a55f5edd8 100644
--- a/util/style/verifiers.py
+++ b/util/style/verifiers.py
@@ -57,8 +57,12 @@ from region import *
from file_types import lang_type
def _modified_regions(old, new):
- m = SequenceMatcher(a=old, b=new, autojunk=False)
-
+ try:
+ m = SequenceMatcher(a=old, b=new, autojunk=False)
+ except TypeError:
+ # autojunk was introduced in Python 2.7. We need a fallback
+ # mechanism to support old Python versions.
+ m = SequenceMatcher(a=old, b=new)
regions = Regions()
for tag, i1, i2, j1, j2 in m.get_opcodes():
if tag != "equal":