Eric Snow added the comment:

Ah, you're talking about deleting Lib/test/__init__.py.  Doing so makes it a 
namespace package.  The loader we use for namespace packages [1] does not have 
a get_filename() method.  So the problem to solve is supporting namespace 
packages in Lib/pyclbr.py.

Regarding your patch, it's okay, but not the best option.  Using 
spec.submodule_search_locations like you are isn't ideal, but works.  However, 
you should be able to leave the is_package() call alone.

TBH, the better option is to use importlib.util.module_from_spec() instead, 
since it does the right thing for you, like setting __path__.

FWIW, I get the same as you by deleting those files and running the following:

  ./python Lib/pyclbr.py Lib/test


[1] 
https://hg.python.org/cpython/file/default/Lib/importlib/_bootstrap_external.py#l991

----------
title: pyclbr.readmodule() and pyclbr.readmodule_ex() don't support packages -> 
pyclbr.readmodule() and pyclbr.readmodule_ex() don't support namespace packages

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26569>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to