[New-bugs-announce] [issue45591] PathFinder does not find namespace packages children

Filipe Laíns report at bugs.python.org
Sat Oct 23 17:28:44 EDT 2021


New submission from Filipe Laíns <lains at riseup.net>:

```
$ tree namespace
namespace/
└── a.py

0 directories, 1 file
```

```
$ ./python
Python 3.9.7 (default, Oct 10 2021, 15:13:22)
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from importlib.machinery import PathFinder
>>> PathFinder.find_
PathFinder.find_distributions(  PathFinder.find_module(         PathFinder.find_spec(
>>> PathFinder.find_spec('namespace')
ModuleSpec(name='namespace', loader=None, submodule_search_locations=_NamespacePath(['/home/anubis/git/cpython/namespace']))
>>> PathFinder.find_spec('namespace.a')
```

Currently, it is unable to find namespace.a, but it should:

```
Python 3.11.0a1+ (heads/main:9e05da6224, Oct 23 2021, 20:36:14) [GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from importlib.machinery import PathFinder
>>> spec = PathFinder.find_spec('namespace')
>>> spec.loader.load_module('namespace.a')
<frozen importlib._bootstrap>:283: DeprecationWarning: the load_module() method is deprecated and slated for removal in Python 3.12; use exec_module() instead
<module 'namespace.a' (<_frozen_importlib_external.NamespaceLoader object at 0x7f81b944f480>)>
```

I can make a PR, but just wanted to make sure the current behavior is not intended.

----------
messages: 404912
nosy: FFY00, brett.cannon, eric.snow, ncoghlan
priority: normal
severity: normal
status: open
title: PathFinder does not find namespace packages children

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45591>
_______________________________________


More information about the New-bugs-announce mailing list