nodejs / node-chakracore

Node.js on ChakraCore :sparkles::turtle::rocket::sparkles:
Other
1.92k stars 342 forks source link

Update cpplint.py for compatibility with Python 3 #576

Closed cclauss closed 6 years ago

cclauss commented 6 years ago

xrange() was removed in Python 3 in favor of range(). This PR ensures similar functionality on both Python 2 and Python 3.

Similar to https://github.com/nodejs/nan/pull/797

Discovered via https://travis-ci.com/nodejs/node/builds/79706150 (https://github.com/nodejs/node/pull/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()):
              ^
Checklist
cclauss commented 6 years ago

Searching for Clang... ERROR: clang++ not found. You could use clang++ from a custom location.

MSLaguana commented 6 years ago

Thanks for the PR! This file looks to be unchanged from the upstream https://github.com/nodejs/node repository, so rather than introducing an unnecessary difference in our fork, could you please open an equivalent PR against them? We'll get the change after it merges in as part of our regular updates from upstream, and this way the greater nodejs community gets the benefit.

cclauss commented 6 years ago

Made in upstream https://github.com/nodejs/node

MSLaguana commented 6 years ago

Thanks!