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.
This commit is contained in:
parent
39e10ced03
commit
f819518158
1 changed files with 6 additions and 2 deletions
|
@ -57,8 +57,12 @@ from region import *
|
||||||
from file_types import lang_type
|
from file_types import lang_type
|
||||||
|
|
||||||
def _modified_regions(old, new):
|
def _modified_regions(old, new):
|
||||||
|
try:
|
||||||
m = SequenceMatcher(a=old, b=new, autojunk=False)
|
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()
|
regions = Regions()
|
||||||
for tag, i1, i2, j1, j2 in m.get_opcodes():
|
for tag, i1, i2, j1, j2 in m.get_opcodes():
|
||||||
if tag != "equal":
|
if tag != "equal":
|
||||||
|
|
Loading…
Reference in a new issue