diff --git a/contrib/check-config.py b/contrib/check-config.py --- a/contrib/check-config.py +++ b/contrib/check-config.py @@ -42,6 +42,14 @@ config:\s(?P\S+\.\S+)$ ''', re.VERBOSE | re.MULTILINE) +if sys.version_info[0] > 2: + def mkstr(b): + if isinstance(b, str): + return b + return b.decode('utf8') +else: + mkstr = lambda x: x + def main(args): for f in args: sect = b'' @@ -92,7 +100,7 @@ # look for ignore markers m = ignorere.search(l) if m: - if m.group('reason') == 'inconsistent': + if m.group('reason') == b'inconsistent': allowinconsistent.add(m.group('config')) else: documented[m.group('config')] = 1 @@ -106,16 +114,20 @@ ctype = 'str' name = m.group('section') + b"." + m.group('option') default = m.group('default') - if default in (None, 'False', 'None', '0', '[]', '""', "''"): + if default in ( + None, b'False', b'None', b'0', b'[]', b'""', b"''"): default = b'' if re.match(b'[a-z.]+$', default): default = b'' if (name in foundopts and (ctype, default) != foundopts[name] and name not in allowinconsistent): - print(l.rstrip()) - print("conflict on %s: %r != %r" % (name, (ctype, default), - foundopts[name])) - print("at %s:%d:" % (f, linenum)) + print(mkstr(l.rstrip())) + fctype, fdefault = foundopts[name] + print("conflict on %s: %r != %r" % ( + mkstr(name), + (mkstr(ctype), mkstr(default)), + (mkstr(fctype), mkstr(fdefault)))) + print("at %s:%d:" % (mkstr(f), linenum)) foundopts[name] = (ctype, default) carryover = b'' else: @@ -132,8 +144,13 @@ name.startswith(b"debug.")): ctype, default = foundopts[name] if default: + if isinstance(default, bytes): + default = mkstr(default) default = ' [%s]' % default - print("undocumented: %s (%s)%s" % (name, ctype, default)) + elif isinstance(default, bytes): + default = mkstr(default) + print("undocumented: %s (%s)%s" % ( + mkstr(name), mkstr(ctype), default)) if __name__ == "__main__": if len(sys.argv) > 1: diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -59,6 +59,7 @@ test-changelog-exec.t test-check-code.t test-check-commit.t +test-check-config.py test-check-execute.t test-check-interfaces.py test-check-module-imports.t