You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2018-04-25.02:58:44.339>created_at=<Date2018-03-23.23:30:41.727>labels= ['interpreter-core', '3.8', 'type-bug', '3.7']
title='PathFinder is twice on sys.meta_path'updated_at=<Date2018-04-25.02:58:44.338>user='https://bugs.python.org/htgoebel'
As of Python 3.7.0b2 _frozen_importlib_external.PathFinder exists twice on sys.meta_path, and it is the same object:
$ python -S
Python 3.7.0b2 (default, Mar 22 2018, 20:09:00)
[GCC 5.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.meta_path)
[<class '_frozen_importlib.BuiltinImporter'>,
<class '_frozen_importlib.FrozenImporter'>,
<class '_frozen_importlib_external.PathFinder'>,
<class '_frozen_importlib_external.PathFinder'>]
>>> print([id(p) for p in sys.meta_path])
[24427944, 24430216, 24517416, 24517416]
>>>
It seems that the problem is that _Py_InitializeEx_Private calls _Py_InitializeCore and _Py_InitializeMainInterpreter. The first one calls at the end initimport that in turns calls importlib._install_external_importers that sets the PathFinder. Then, _Py_InitializeMainInterpreter calls initexternalimport that in turns calls again importlib._install_external_importers and therefore we end with two PathFinders in sys.meta_path.
I think the solution is removing the call to initexternalimport in _Py_InitializeMainInterpreter as it has been alreade initialized by _Py_InitializeCore.
Calling initexternalimports InitalizeMainInterpreter and from new_interpreter is right, since we only want these importers on the metapath after we know sys.path has been configured appropriately.
It's the call from InitializeCore that's questionable, since we haven't finished setting up sys.path at that point.
New changeset 0977091 by Nick Coghlan (Pablo Galindo) in branch 'master': bpo-33128 Fix duplicated call to importlib._install_external_importers (GH-6273) 0977091
New changeset 52a5a17 by Miss Islington (bot) in branch '3.7': bpo-33128 Fix duplicated call to importlib._install_external_importers (GH-6273) 52a5a17
Activity
htgoebel commentedon Mar 23, 2018
As of Python 3.7.0b2 _frozen_importlib_external.PathFinder exists twice on sys.meta_path, and it is the same object:
ned-deily commentedon Mar 24, 2018
Thanks for the report. git bisect result:
1abcf67 is the first bad commit
commit 1abcf67
Author: Eric Snow <ericsnowcurrently@gmail.com>
Date: Tue May 23 21:46:51 2017 -0700
pablogsal commentedon Mar 27, 2018
It seems that the problem is that
_Py_InitializeEx_Privatecalls_Py_InitializeCoreand_Py_InitializeMainInterpreter. The first one calls at the endinitimportthat in turns callsimportlib._install_external_importersthat sets the PathFinder. Then,_Py_InitializeMainInterpretercallsinitexternalimportthat in turns calls againimportlib._install_external_importersand therefore we end with two PathFinders in sys.meta_path.I think the solution is removing the call to initexternalimport in
_Py_InitializeMainInterpreteras it has been alreade initialized by_Py_InitializeCore.pablogsal commentedon Mar 27, 2018
The same problem happens in
new_interpreteras far as I understand.ncoghlan commentedon Mar 29, 2018
Calling initexternalimports InitalizeMainInterpreter and from new_interpreter is right, since we only want these importers on the metapath after we know sys.path has been configured appropriately.
It's the call from InitializeCore that's questionable, since we haven't finished setting up sys.path at that point.
ncoghlan commentedon Apr 25, 2018
New changeset 0977091 by Nick Coghlan (Pablo Galindo) in branch 'master':
bpo-33128 Fix duplicated call to importlib._install_external_importers (GH-6273)
0977091
miss-islington commentedon Apr 25, 2018
New changeset 52a5a17 by Miss Islington (bot) in branch '3.7':
bpo-33128 Fix duplicated call to importlib._install_external_importers (GH-6273)
52a5a17
ncoghlan commentedon Apr 25, 2018
Hartmut, thanks for the issue report, and Pablo, thanks for the PR to resolve it!