Skip to content

Commit 89be4df

Browse files
authored
Define xrange for use under Python 3
Define xrange() for Python 3. I is only used on for loops so this is safe.
2 parents 209d381 + 099f059 commit 89be4df

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

cpplint/cpplint.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252
import sys
5353
import unicodedata
5454

55+
try:
56+
xrange # Python 2
57+
except NameError:
58+
xrange = range # Python 3
59+
5560

5661
_USAGE = """
5762
Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]

cpplint/cpplint_unittest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343

4444
import cpplint
4545

46+
try:
47+
xrange # Python 2
48+
except NameError:
49+
xrange = range # Python 3
50+
4651

4752
# This class works as an error collector and replaces cpplint.Error
4853
# function for the unit tests. We also verify each category we see

0 commit comments

Comments
 (0)