Patchwork [1,of,6,resend] import-checker: fix names of dynamically loaded modules

mail settings
Submitter Mads Kiilerich
Date Feb. 5, 2014, 1:04 a.m.
Message ID <0929a6dcc91a20392b14.1391562250@localhost.localdomain>
Download mbox | patch
Permalink /patch/3478/
State Accepted
Commit 4990abb4729d71acedb92bda7ae84909ef98a1ba
Headers show


Mads Kiilerich - Feb. 5, 2014, 1:04 a.m.
# HG changeset patch
# User Mads Kiilerich <>
# Date 1391560233 -3600
#      Wed Feb 05 01:30:33 2014 +0100
# Node ID 0929a6dcc91a20392b14d72ef8aa9618f34ab5a7
# Parent  ec5d4287a4269bc939e203c975af8585570404c6
import-checker: fix names of dynamically loaded modules

The import checker found standard library modules such as
lib-dynload/ but saw that as a 'zlibmodule' module, not as the
'zlib' module.

Debian ships Python with most modules built-in and this incorrect handling of
dynamic modules did thus not cause problems on that platform.

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.

This change makes test-module-imports.t pass on Fedora.


diff --git a/contrib/ b/contrib/
--- a/contrib/
+++ b/contrib/
@@ -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/')
+    >>> dotted_name_of_path('')
+    'zlib'
     parts = path.split('/')
     parts[-1] = parts[-1][:-3] # remove .py
+    if parts[-1].endswith('module'):
+        parts[-1] = parts[-1][:-6]
     return '.'.join(parts)