Skip to content

Commit a80feff

Browse files
committed
bug 1463425 - Fix flake8/pep8 issue by hand in config/ r=gps
MozReview-Commit-ID: 6B60uh4n2nY --HG-- extra : rebase_source : 4fd44789a9ee6376c72bae1132f73c81dd1eacbc
1 parent 3d08581 commit a80feff

18 files changed

+37
-46
lines changed

config/MozZipFile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def writestr(self, zinfo_or_arcname, bytes):
5959
# as the old, reuse the existing entry.
6060

6161
doSeek = False # store if we need to seek to the eof after overwriting
62-
if self.NameToInfo.has_key(zinfo.filename):
62+
if zinfo.filename in self.NameToInfo:
6363
# Find the last ZipInfo with our name.
6464
# Last, because that's catching multiple overwrites
6565
i = len(self.filelist)

config/check_js_msg_encoding.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
# License, v. 2.0. If a copy of the MPL was not distributed with this
44
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
55

6-
#----------------------------------------------------------------------------
6+
# ----------------------------------------------------------------------------
77
# This script checks encoding of the files that define JSErrorFormatStrings.
88
#
99
# JSErrorFormatString.format member should be in ASCII encoding.
10-
#----------------------------------------------------------------------------
10+
# ----------------------------------------------------------------------------
1111

1212
from __future__ import print_function
1313

@@ -41,7 +41,7 @@ def check_single_file(filename):
4141
data = f.read()
4242
try:
4343
data.decode(expected_encoding)
44-
except:
44+
except Exception:
4545
log_fail(filename, 'not in {} encoding'.format(expected_encoding))
4646

4747
log_pass(filename, 'ok')

config/check_js_opcode.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# License, v. 2.0. If a copy of the MPL was not distributed with this
44
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
55

6-
#----------------------------------------------------------------------------
6+
# ----------------------------------------------------------------------------
77
# This script checks bytecode documentation in js/src/vm/Opcodes.h
8-
#----------------------------------------------------------------------------
8+
# ----------------------------------------------------------------------------
99

1010
from __future__ import print_function
1111

config/check_source_count.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# check_source_count.py.
1212
from __future__ import print_function
1313
import sys
14-
import os
1514
import re
1615

1716
search_string = sys.argv[1]

config/check_spidermonkey_style.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# License, v. 2.0. If a copy of the MPL was not distributed with this
44
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
55

6-
#----------------------------------------------------------------------------
6+
# ----------------------------------------------------------------------------
77
# This script checks various aspects of SpiderMonkey code style. The current checks are as
88
# follows.
99
#
@@ -33,7 +33,7 @@
3333
# statement should go, even to a human. Therefore, we check the #include
3434
# statements within each #if/#endif block (including nested ones) in
3535
# isolation, but don't try to do any order checking between such blocks.
36-
#----------------------------------------------------------------------------
36+
# ----------------------------------------------------------------------------
3737

3838
from __future__ import print_function
3939

@@ -340,7 +340,7 @@ def check_style(enable_fixup):
340340
def module_name(name):
341341
'''Strip the trailing .cpp, .h, inlines.h or -inl.h from a filename.'''
342342

343-
return name.replace('inlines.h', '').replace('-inl.h', '').replace('.h', '').replace('.cpp', '')
343+
return name.replace('inlines.h', '').replace('-inl.h', '').replace('.h', '').replace('.cpp', '') # NOQA: E501
344344

345345

346346
def is_module_header(enclosing_inclname, header_inclname):
@@ -773,8 +773,8 @@ def main():
773773
elif sys.argv[1:] == []:
774774
fixup = False
775775
else:
776-
print("TEST-UNEXPECTED-FAIL | check_spidermonkey_style.py | unexpected command line options: " +
777-
repr(sys.argv[1:]))
776+
print("TEST-UNEXPECTED-FAIL | check_spidermonkey_style.py | unexpected command "
777+
"line options: " + repr(sys.argv[1:]))
778778
sys.exit(1)
779779

780780
ok = check_style(fixup)

config/check_vanilla_allocations.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# License, v. 2.0. If a copy of the MPL was not distributed with this
44
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
55

6-
#----------------------------------------------------------------------------
6+
# ----------------------------------------------------------------------------
77
# All heap allocations in SpiderMonkey must go through js_malloc, js_calloc,
88
# js_realloc, and js_free. This is so that any embedder who uses a custom
99
# allocator (by defining JS_USE_CUSTOM_ALLOCATOR) will see all heap allocation
@@ -34,7 +34,7 @@
3434
# because vanilla delete/delete[] calls don't make sense without corresponding
3535
# vanilla new/new[] calls, and any explicit calls will be caught by Valgrind's
3636
# mismatched alloc/free checking.
37-
#----------------------------------------------------------------------------
37+
# ----------------------------------------------------------------------------
3838

3939
from __future__ import print_function
4040

config/createprecomplete.py

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# longer present in a complete update. The current working directory is used for
77
# the location to enumerate and to create the precomplete file.
88

9-
import sys
109
import os
1110

1211

config/external/ffi/preprocess_libffi_asm.py

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import shlex
1212
import subprocess
1313

14+
1415
def main(output, input_asm, defines, includes):
1516
defines = shlex.split(defines)
1617
includes = shlex.split(includes)

config/external/ffi/subst_header.py

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import buildconfig
99
from mozbuild.preprocessor import Preprocessor
1010

11+
1112
def main(output, input_file):
1213
pp = Preprocessor()
1314
pp.context.update({
@@ -21,5 +22,6 @@ def main(output, input_file):
2122
pp.out = output
2223
pp.do_include(input_file)
2324

25+
2426
if __name__ == '__main__':
2527
main(*sys.agv[1:])

config/find_OOM_errors.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@
1616
"""
1717

1818

19-
import hashlib
2019
import re
2120
import shlex
2221
import subprocess
2322
import sys
2423
import threading
25-
import time
2624

2725
from optparse import OptionParser
2826

@@ -69,7 +67,7 @@ def run(self):
6967
stdout_worker.join()
7068
stderr_worker.join()
7169

72-
except KeyboardInterrupt as e:
70+
except KeyboardInterrupt:
7371
sys.exit(-1)
7472

7573
stdout, stderr = stdout_worker.all, stderr_worker.all
@@ -135,7 +133,7 @@ def clean_voutput(err):
135133
r"\1x", err, flags=re.MULTILINE)
136134
err = re.sub(r"(^\s+Invalid read of size )\d+",
137135
r"\1x", err, flags=re.MULTILINE)
138-
err = re.sub(r"(^\s+Address 0x)[0-9A-Fa-f]+( is )\d+( bytes inside a block of size )[0-9,]+( free'd)",
136+
err = re.sub(r"(^\s+Address 0x)[0-9A-Fa-f]+( is )\d+( bytes inside a block of size )[0-9,]+( free'd)", # NOQA: E501
139137
r"\1\2\3\4", err, flags=re.MULTILINE)
140138

141139
# Skip the repeating bit due to the segfault
@@ -170,7 +168,7 @@ def remove_failed_allocation_backtraces(err):
170168

171169

172170
def clean_output(err):
173-
err = re.sub(r"^js\(\d+,0x[0-9a-f]+\) malloc: \*\*\* error for object 0x[0-9a-f]+: pointer being freed was not allocated\n\*\*\* set a breakppoint in malloc_error_break to debug\n$",
171+
err = re.sub(r"^js\(\d+,0x[0-9a-f]+\) malloc: \*\*\* error for object 0x[0-9a-f]+: pointer being freed was not allocated\n\*\*\* set a breakpoint in malloc_error_break to debug\n$", # NOQA: E501
174172
"pointer being freed was not allocated", err, flags=re.MULTILINE)
175173

176174
return err
@@ -213,7 +211,7 @@ def clean_output(err):
213211
(OPTIONS, args) = parser.parse_args()
214212

215213

216-
if OPTIONS.regression != None:
214+
if OPTIONS.regression is not None:
217215
# TODO: This should be expanded as we get a better hang of the OOM problems.
218216
# For now, we'll just check that the number of OOMs in one short file does not
219217
# increase.
@@ -226,7 +224,7 @@ def clean_output(err):
226224
files = [f for f in files if f.find(args[0]) != -1]
227225

228226

229-
if OPTIONS.regression == None:
227+
if OPTIONS.regression is None:
230228
# Don't use a logfile, this is automated for tinderbox.
231229
log = file("../OOM_log", "w")
232230

@@ -245,7 +243,7 @@ def clean_output(err):
245243
# TODO: revisit this.
246244
for i in range(20, max):
247245

248-
if OPTIONS.regression == None:
246+
if OPTIONS.regression is None:
249247
print("Testing allocation {0}/{1} in {2}".format(i, max, f))
250248
else:
251249
# something short for tinderbox, no space or \n
@@ -261,7 +259,7 @@ def clean_output(err):
261259
# Failure
262260
else:
263261

264-
if OPTIONS.regression != None:
262+
if OPTIONS.regression is not None:
265263
# Just count them
266264
num_failures += 1
267265
continue
@@ -340,13 +338,13 @@ def clean_output(err):
340338
log.write("\n")
341339
log.flush()
342340

343-
if OPTIONS.regression == None:
341+
if OPTIONS.regression is None:
344342
count_lines()
345343

346344
print()
347345

348346
# Do the actual regression check
349-
if OPTIONS.regression != None:
347+
if OPTIONS.regression is not None:
350348
expected_num_failures = OPTIONS.regression
351349

352350
if num_failures != expected_num_failures:

config/make-stl-wrappers.py

-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44
from __future__ import print_function
55
import os
6-
import re
76
import string
8-
import sys
97
from mozbuild.util import FileAvoidWrite
108

119

config/make-system-wrappers.py

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44
from __future__ import print_function
55
import os
6-
import sys
76
from mozbuild.util import FileAvoidWrite
87

98
header_template = '''#pragma GCC system_header

config/nsinstall.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import os.path
1717
import sys
1818
import shutil
19-
import stat
2019

2120

2221
def _nsinstall_internal(argv):
@@ -57,7 +56,7 @@ def BadArg(option, opt, value, parser):
5756
# mode is specified
5857
try:
5958
options.m = int(options.m, 8)
60-
except:
59+
except Exception:
6160
sys.stderr.write('nsinstall: {0} is not a valid mode\n'
6261
.format(options.m))
6362
return 1
@@ -89,7 +88,7 @@ def maybe_create_dir(dir, mode, try_again):
8988
return 0
9089

9190
if options.X:
92-
options.X = [os.path.abspath(p) for p in options.X]
91+
options.X = [os.path.abspath(path) for path in options.X]
9392

9493
if options.D:
9594
return maybe_create_dir(args[0], options.m, True)

config/printconfigsetting.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
try:
1111
(file, section, key) = sys.argv[1:]
1212
except ValueError:
13-
print "Usage: printconfigsetting.py <file> <section> <setting>"
13+
print("Usage: printconfigsetting.py <file> <section> <setting>")
1414
sys.exit(1)
1515

1616
with open(file) as fh:
@@ -25,7 +25,7 @@
2525
sys.exit(1)
2626

2727
try:
28-
print s[key]
28+
print(s[key])
2929
except KeyError:
3030
print >>sys.stderr, "Key %s not found." % key
3131
sys.exit(1)

config/rebuild_check.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def rebuild_check(args):
2020
deps = args[1:]
2121
t = mtime(target)
2222
if t < 0:
23-
print target
23+
print(target)
2424
return
2525

2626
newer = []
@@ -33,15 +33,15 @@ def rebuild_check(args):
3333
newer.append(dep)
3434

3535
if newer and removed:
36-
print 'Rebuilding %s because %s changed and %s was removed' % (
37-
target, ', '.join(newer), ', '.join(removed))
36+
print('Rebuilding %s because %s changed and %s was removed' % (
37+
target, ', '.join(newer), ', '.join(removed)))
3838
elif newer:
39-
print 'Rebuilding %s because %s changed' % (target, ', '.join(newer))
39+
print('Rebuilding %s because %s changed' % (target, ', '.join(newer)))
4040
elif removed:
41-
print 'Rebuilding %s because %s was removed' % (
42-
target, ', '.join(removed))
41+
print('Rebuilding %s because %s was removed' % (
42+
target, ', '.join(removed)))
4343
else:
44-
print 'Rebuilding %s for an unknown reason' % target
44+
print('Rebuilding %s for an unknown reason' % target)
4545

4646

4747
if __name__ == '__main__':

config/tests/unit-mozunit.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5-
import sys
65
import os
76
from mozunit import main, MockedOpen
87
import unittest

config/tests/unit-printprereleasesuffix.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import unittest
22

3-
import sys
4-
import os.path
53
import mozunit
64

75
from printprereleasesuffix import get_prerelease_suffix

config/tests/unitMozZipFile.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import shutil
88
import os
9-
import re
109
import sys
1110
import random
1211
import copy
@@ -16,7 +15,7 @@
1615
Test case infrastructure for MozZipFile.
1716
1817
This isn't really a unit test, but a test case generator and runner.
19-
For a given set of files, lengths, and number of writes, we create
18+
For a given set of files, lengths, and number of writes, we create
2019
a testcase for every combination of the three. There are some
2120
symmetries used to reduce the number of test cases, the first file
2221
written is always the first file, the second is either the first or

0 commit comments

Comments
 (0)