Patchwork [1,of,2] import-checker: normalize directory separator to get module name on Windows

login
register
mail settings
Submitter Yuya Nishihara
Date Jan. 4, 2016, 2:58 p.m.
Message ID <937c6a6dac98baaed78a.1451919504@mimosa>
Download mbox | patch
Permalink /patch/12506/
State Accepted
Headers show

Comments

Yuya Nishihara - Jan. 4, 2016, 2:58 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# 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.
Gregory Szorc - Jan. 4, 2016, 5:32 p.m.
> On Jan 4, 2016, at 06:58, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # 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
> 

Series LGTM. Would queue if I could.

> 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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
Yuya Nishihara - Jan. 5, 2016, 2:30 p.m.
On Mon, 4 Jan 2016 09:32:46 -0800, Gregory Szorc wrote:
> > On Jan 4, 2016, at 06:58, Yuya Nishihara <yuya@tcha.org> wrote:
> > 
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # 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
> > 
> 
> Series LGTM. Would queue if I could.

Thanks, pushed to the clowncopter.

Patch

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