From patchwork Mon Jan 20 00:32:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2,of,8] import-checker: fix names of dynamically loaded modules From: Mads Kiilerich X-Patchwork-Id: 3388 Message-Id: To: mercurial-devel@selenic.com Date: Mon, 20 Jan 2014 01:32:26 +0100 # HG changeset patch # User Mads Kiilerich # Date 1390147816 -3600 # Sun Jan 19 17:10:16 2014 +0100 # Node ID ae7f49d0e3918ba9f899c8c4d6c976ba9f1fc30d # Parent 3a963f886a2374b0221c73cdcba4e4bac2981852 import-checker: fix names of dynamically loaded modules The import checker found standard library modules like lib-dynload/zlibmodule.so but saw that as a zlibmodule module, not as the zlib module. Debian ships Python with most modules built in and the incorrect handling of dynamic modules did thus not cause problems. Fedora ships Python with as many modules as possible loaded dynamically. That made the import checker tests fail with incorrect classification of the following modules: array fcntl grp itertools time zlib. diff --git a/contrib/import-checker.py b/contrib/import-checker.py --- a/contrib/import-checker.py +++ b/contrib/import-checker.py @@ -11,12 +11,15 @@ import zlib def dotted_name_of_path(path): """Given a relative path to a source file, return its dotted module name. - >>> dotted_name_of_path('mercurial/error.py') 'mercurial.error' + >>> dotted_name_of_path('zlibmodule.so') + 'zlib' """ parts = path.split('/') parts[-1] = parts[-1][:-3] # remove .py + if parts[-1].endswith('module'): + parts[-1] = parts[-1][:-6] return '.'.join(parts)