Jim Li <ji...@bcgsc.ca> added the comment:

Hi Eric,

Sorry for the late reply. I think I did not accurately describe the issue at 
all. As a minimal example, set up two virtual environments, one from 2.7.x, one 
from 3.7.2.

When you are in the virtual environment, do
- pip install protobuf==3.3.0
- python (to go into compiler)
- import google
- print(type(google.__path__))

The 2.7.x would tell you it's a <type 'list'>
The 3.7.2 would tell you it's a 
<class'_frozen_importlib_external._NamespacePath'>

Since it's not a list, some behaviours are gone, e.g., insert. I'm not trying 
to manipulate protobuf package's __path__, but trying to upgrade a legacy 
codebase, the legacy codebase does something like:

module.insert(0, 'some/path'), which breaks under python3, because it's not a 
list anymore, but a <class'_frozen_importlib_external._NamespacePath'>.


I believe the problem comes from the 'top level entry point'. For example, when 
you have 2 separate packages but they were organized under the same namespace.

E.g., in their setup.py

Package A:

    packages=[
        "orange",
        "orange.schemas",
    ],
    namespace_packages=["orange"]

Package B:
    packages=[
        "orange",
        "orange.server",
    ],
    namespace_packages=["orange"]

The problem comes from when you try to do `import orange`, and do operations 
with orange.__path__ here. In Python 2.7, it's a list; in Python 3.7, it's a 
<class '_frozen_importlib_external._NamespacePath'>

----------

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

Reply via email to