Mercurial > hg
changeset 33890:3de9a2df6411
contrib: have import-checker work mostly with native strings for mod names
Module names are a bit awkward to deal with portably otherwise.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Tue, 22 Aug 2017 12:59:21 -0400 |
parents | f672d060a931 |
children | 42bc7f39376b |
files | contrib/import-checker.py |
diffstat | 1 files changed, 7 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/import-checker.py Wed Aug 23 12:35:03 2017 -0700 +++ b/contrib/import-checker.py Tue Aug 22 12:59:21 2017 -0400 @@ -147,6 +147,8 @@ >>> fromlocal2('bar', 2) ('foo.bar', 'foo.bar.__init__', True) """ + if not isinstance(modulename, str): + modulename = modulename.decode('ascii') prefix = '.'.join(modulename.split('.')[:-1]) if prefix: prefix += '.' @@ -406,6 +408,8 @@ * Certain modules must be aliased to alternate names to avoid aliasing and readability problems. See `requirealias`. """ + if not isinstance(module, str): + module = module.decode('ascii') topmodule = module.split('.')[0] fromlocal = fromlocalfunc(module, localmods) @@ -724,6 +728,9 @@ localmodpaths[modname] = source_path localmods = populateextmods(localmodpaths) for localmodname, source_path in sorted(localmodpaths.items()): + if not isinstance(localmodname, bytes): + # This is only safe because all hg's files are ascii + localmodname = localmodname.encode('ascii') for src, modname, name, line in sources(source_path, localmodname): try: used_imports[modname] = sorted(