Issue #53 new

[PATCH] fix "replace_paths" in combination with "namespace_packages"

Gaëtan de Menten
created an issue

Here is an excerpt of my which caused an exception (with release 4.3.2 on Windows 7):

"replace_paths": [("*", "")],
"namespace_packages": ["mpl_toolkits"],

Attached is a patch (against release 4.3.2) to fix the problem.

Comments (2)

  1. Thomas Kluyver

    Thanks. Questions about the fix:

    • Is the bug actually that file shouldn't be None for modules in namespace packages? i.e. should this be fixed by setting mod.file, instead of ignoring the case where it's None?
    • The patch checks topLevelModule.file inside a for loop, but there's nothing within that loop that can change it. So if it's None the first time, it will be None on each subsequent iteration, and also when the function recurses in the next code block. So it can be done outside the loop, and just return co unmodified if necessary.
  2. Gaëtan de Menten reporter
    • It might be better, I don't know. I can just tell you that my fix results in an (apparent) correct behavior.
    • You are right. I tried to produce a minimal fix/patch. But given the large return statement and the fact that it needs to be different on py3, I wouldn't bother checking it before the loop, I would only replace "continue" by "break" in my patch. Just my 2c. Do whatever is best for you.
  3. Log in to comment