[New-bugs-announce] [issue35791] Unexpected exception with importlib

Ronald Oussoren report at bugs.python.org
Sun Jan 20 12:38:23 EST 2019

New submission from Ronald Oussoren <ronaldoussoren at mac.com>:

Using Python 3.7.2 on macOS 10.14 I get an unexpected exception when calling "importlib.util.find_spec('py')" after importing "py". find_spec works as expected before I import 'py'. 

See the repl session below:

Python 3.7.2 (v3.7.2:9a3ffc0492, Dec 24 2018, 02:44:43) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import importlib.util
>>> importlib.util.find_spec("py")
ModuleSpec(name='py', loader=<_frozen_importlib_external.SourceFileLoader object at 0x10a953fd0>, origin='/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/py/__init__.py', submodule_search_locations=['/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/py'])
>>> import py
>>> importlib.util.find_spec("py")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/util.py", line 111, in find_spec
    raise ValueError('{}.__spec__ is not set'.format(name)) from None
ValueError: py.__spec__ is not set

This is with py version 1.7.0 installed (pip install py)

components: Library (Lib)
messages: 334094
nosy: brett.cannon, eric.snow, ncoghlan, ronaldoussoren
priority: normal
severity: normal
status: open
title: Unexpected exception with importlib
type: behavior
versions: Python 3.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list