Skip to content

Commit

Permalink
Update cpplint.py for compatibility with Python 3
Browse files Browse the repository at this point in the history
__xrange()__ was removed in Python 3 in favor of __range()__.  This PR ensures similar functionality on both Python 2 and Python 3.

Similar to nodejs/nan#797

Discovered via https://travis-ci.com/nodejs/node/builds/79706150 (nodejs/node#21942)


flake8 testing of https://github.com/nodejs/node-chakracore on Python 3.7.0

$ __flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics__
```
./tools/cpplint.py:1471:12: F821 undefined name 'xrange'
  for i in xrange(startpos, len(line)):
           ^
./tools/cpplint.py:1700:15: F821 undefined name 'xrange'
  for line in xrange(1, min(len(lines), 11)):
              ^
./tools/cpplint.py:1828:12: F821 undefined name 'xrange'
  for i in xrange(1, len(raw_lines) - 1):
           ^
./tools/cpplint.py:2169:14: F821 undefined name 'xrange'
    for i in xrange(linenum - 1, self.starting_linenum, -1):
             ^
./tools/cpplint.py:2950:26: F821 undefined name 'xrange'
    for start_linenum in xrange(linenum, clean_lines.NumLines()):
                         ^
./tools/cpplint.py:3437:14: F821 undefined name 'xrange'
    for i in xrange(first_line, last_line + 1, 1):
             ^
./tools/cpplint.py:3501:19: F821 undefined name 'xrange'
    for offset in xrange(endlinenum + 1,
                  ^
./tools/cpplint.py:4047:14: F821 undefined name 'xrange'
    for i in xrange(linenum + 1, end_line):
             ^
./tools/cpplint.py:4218:23: F821 undefined name 'unicode'
  if isinstance(line, unicode):
                      ^
./tools/cpplint.py:4870:12: F821 undefined name 'xrange'
  for i in xrange(linenum, max(-1, linenum - 10), -1):
           ^
./tools/cpplint.py:4891:12: F821 undefined name 'xrange'
  for i in xrange(linenum, max(-1, linenum - 10), -1):
           ^
./tools/cpplint.py:4907:12: F821 undefined name 'xrange'
  for i in xrange(linenum, 1, -1):
           ^
./tools/cpplint.py:5008:20: F821 undefined name 'xrange'
          for i in xrange(startline, linenum + 1):
                   ^
./tools/cpplint.py:5032:14: F821 undefined name 'xrange'
    for i in xrange(linenum - 1, max(0, linenum - 10), -1):
             ^
./tools/cpplint.py:5063:14: F821 undefined name 'xrange'
    for i in xrange(2):
             ^
./tools/cpplint.py:5226:14: F821 undefined name 'xrange'
    for i in xrange(linenum - 1, max(0, linenum - 5), -1):
             ^
./tools/cpplint.py:5442:18: F821 undefined name 'xrange'
  for linenum in xrange(clean_lines.NumLines()):
                 ^
./tools/cpplint.py:5573:21: F821 undefined name 'xrange'
  for start_line in xrange(linenum, min(linenum + 3, clean_lines.NumLines())):
                    ^
./tools/cpplint.py:5588:12: F821 undefined name 'xrange'
  for i in xrange(end_line, min(end_line + 3, clean_lines.NumLines())):
           ^
./tools/cpplint.py:5845:15: F821 undefined name 'xrange'
  for line in xrange(clean_lines.NumLines()):
              ^
```
  • Loading branch information
cclauss committed Jul 23, 2018
1 parent 7b87f70 commit 2b5184e
Showing 1 changed file with 240 additions and 144 deletions.
Loading

0 comments on commit 2b5184e

Please sign in to comment.