# HG changeset patch # User timeless # Date 1459313716 0 # Node ID a274c4f9087ac3716f8c2a6940eb5507ae027fe9 # Parent e44f671018e3cae0cb986a7e1972868288ff7da5 py3: use print_function in import-checker diff -r e44f671018e3 -r a274c4f9087a contrib/import-checker.py --- a/contrib/import-checker.py Wed Mar 30 04:50:19 2016 +0000 +++ b/contrib/import-checker.py Wed Mar 30 04:55:16 2016 +0000 @@ -1,6 +1,6 @@ #!/usr/bin/env python -from __future__ import absolute_import +from __future__ import absolute_import, print_function import ast import collections @@ -544,11 +544,12 @@ All module names recorded in `imports` should be absolute one. + >>> from __future__ import print_function >>> imports = {'top.foo': ['top.bar', 'os.path', 'top.qux'], ... 'top.bar': ['top.baz', 'sys'], ... 'top.baz': ['top.foo'], ... 'top.qux': ['top.foo']} - >>> print '\\n'.join(sorted(find_cycles(imports))) + >>> print('\\n'.join(sorted(find_cycles(imports)))) top.bar -> top.baz -> top.foo -> top.bar top.foo -> top.qux -> top.foo """ @@ -566,7 +567,7 @@ def main(argv): if len(argv) < 2 or (argv[1] == '-' and len(argv) > 2): - print 'Usage: %s {-|file [file] [file] ...}' + print('Usage: %s {-|file [file] [file] ...}') return 1 if argv[1] == '-': argv = argv[:1] @@ -584,7 +585,7 @@ imported_modules(src, modname, localmods, ignore_nested=True)) for error, lineno in verify_import_convention(modname, src, localmods): any_errors = True - print '%s:%d: %s' % (source_path, lineno, error) + print('%s:%d: %s' % (source_path, lineno, error)) f.close() cycles = find_cycles(used_imports) if cycles: @@ -596,7 +597,7 @@ # of cycles that are effectively duplicates. if first in firstmods: continue - print 'Import cycle:', c + print('Import cycle:', c) firstmods.add(first) any_errors = True return any_errors != 0 diff -r e44f671018e3 -r a274c4f9087a tests/test-check-py3-compat.t --- a/tests/test-check-py3-compat.t Wed Mar 30 04:50:19 2016 +0000 +++ b/tests/test-check-py3-compat.t Wed Mar 30 04:55:16 2016 +0000 @@ -3,7 +3,6 @@ $ cd "$TESTDIR"/.. $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs python contrib/check-py3-compat.py - contrib/import-checker.py requires print_function doc/check-seclevel.py not using absolute_import doc/gendoc.py not using absolute_import doc/hgmanpage.py not using absolute_import @@ -112,7 +111,6 @@ #if py3exe $ hg files 'set:(**.py)' | sed 's|\\|/|g' | xargs $PYTHON3 contrib/check-py3-compat.py contrib/check-code.py: invalid syntax: (unicode error) 'unicodeescape' codec can't decode bytes in position *-*: malformed \N character escape (, line *) (glob) - contrib/import-checker.py: invalid syntax: Missing parentheses in call to 'print' (, line *) (glob) doc/hgmanpage.py: invalid syntax: invalid syntax (, line *) (glob) hgext/acl.py: error importing: No module named 'cStringIO' (error at parsers.py:*) (glob) hgext/automv.py: error importing module: invalid syntax (commands.py, line *) (line *) (glob)