[pypy-issue] Issue #2834: import pypy3 FileFinder path hooks and frozen importers duplicated (pypy/pypy)
Alexandre Vincent
issues-reply at bitbucket.org
Tue May 22 09:23:38 EDT 2018
New issue 2834: import pypy3 FileFinder path hooks and frozen importers duplicated
https://bitbucket.org/pypy/pypy/issues/2834/import-pypy3-filefinder-path-hooks-and
Alexandre Vincent:
I am using a custom built pypy3 (not available as package on my platform)
```
Python 3.5.3 (39fd746993fe, May 22 2018, 12:05:13)
[PyPy 6.1.0-alpha0 with GCC 5.4.0 20160609] on linux
```
I noticed that :
```
PyDev console: starting.
Python 3.5.3 (39fd746993fe, May 22 2018, 12:05:13)
[PyPy 6.1.0-alpha0 with GCC 5.4.0 20160609] on linux
>>>> import sys
>>>> import pprint
>>>> pprint.pprint(sys.path_hooks)
[<function FileFinder.path_hook.<locals>.path_hook_for_FileFinder at 0x00007faecf8c4b20>,
<class 'zipimporter'>,
<function FileFinder.path_hook.<locals>.path_hook_for_FileFinder at 0x00007faed00660c0>]
>>>> pprint.pprint(sys.meta_path)
[<class '_frozen_importlib.BuiltinImporter'>,
<class '_frozen_importlib.FrozenImporter'>,
<class '_frozen_importlib_external.PathFinder'>,
<class '_frozen_importlib.BuiltinImporter'>,
<class '_frozen_importlib.FrozenImporter'>,
<class '_frozen_importlib_external.PathFinder'>]
```
The basic hooks are duplicated.
To compare the CPython3.5 behavior is :
```
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import pprint
>>> pprint.pprint(sys.path_hooks)
[<class 'zipimport.zipimporter'>,
<function FileFinder.path_hook.<locals>.path_hook_for_FileFinder at 0x7f7c96ff3950>]
>>> pprint.pprint(sys.meta_path)
[<class '_frozen_importlib.BuiltinImporter'>,
<class '_frozen_importlib.FrozenImporter'>,
<class '_frozen_importlib_external.PathFinder'>]
>>>
```
I noticed it because it breaks a logic in a package I am developing, that deals with imports. Also, the symptom is the same on my travis build with pypy3 : https://travis-ci.org/asmodehn/palimport/builds/382038623 . I am guessing the reason is the same as well, and therefore would not be due to my custom build.
For the record, this doesn't occur at all on python2, but the duplicated objects are new in python3.
More information about the pypy-issue
mailing list