From patchwork Mon Jan 4 14:58:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1, of, 2] import-checker: normalize directory separator to get module name on Windows From: Yuya Nishihara X-Patchwork-Id: 12506 Message-Id: <937c6a6dac98baaed78a.1451919504@mimosa> To: mercurial-devel@selenic.com Date: Mon, 04 Jan 2016 23:58:24 +0900 # HG changeset patch # User Yuya Nishihara # Date 1451227699 -32400 # Sun Dec 27 23:48:19 2015 +0900 # Node ID 937c6a6dac98baaed78a5052890bc630e09b6848 # Parent b8405d739149cdd6d8d9bd5e3dd2ad8487b1f09a import-checker: normalize directory separator to get module name on Windows It didn't work if a path contains "\\". Therefore, ctypes.util couldn't be found on Windows. diff --git a/contrib/import-checker.py b/contrib/import-checker.py --- a/contrib/import-checker.py +++ b/contrib/import-checker.py @@ -61,7 +61,7 @@ def dotted_name_of_path(path, trimpure=F >>> dotted_name_of_path('zlibmodule.so') 'zlib' """ - parts = path.split('/') + parts = path.replace(os.sep, '/').split('/') parts[-1] = parts[-1].split('.', 1)[0] # remove .py and .so and .ARCH.so if parts[-1].endswith('module'): parts[-1] = parts[-1][:-6] @@ -180,7 +180,7 @@ def list_stdlib_modules(): for m in ['msvcrt', '_winreg']: yield m # These get missed too - for m in 'ctypes', 'ctypes.util', 'email', 'logging', 'multiprocessing': + for m in 'ctypes', 'email', 'logging', 'multiprocessing': yield m yield 'builtins' # python3 only for m in 'fcntl', 'grp', 'pwd', 'termios': # Unix only