Author kxrob
Recipients kxrob
Date 2021-02-22.17:48:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
When pyclbr.readmodule_ex() is traversing "import __main__" or another 
module without __spec__, it dies completely 
with "ValueError: __main__.__spec__ is None / is not set".

=> It should at least continue with the (big) rest 
as the comment in _ModuleBrowser.visit_Import() says:
            # If we can't find or parse the imported module,
            # too bad -- don't die here.

And optionally fall back to using __file__ when present?

Traceback (most recent call last):
  File "C:\Python310\Lib\site-packages\pythonwin\pywin\framework\editor\", line 128, in OnActivateView
  File "C:\Python310\Lib\site-packages\pythonwin\pywin\framework\editor\", line 181, in CheckRefreshList
  File "C:\Python310\Lib\site-packages\pythonwin\pywin\framework\editor\", line 173, in CheckMadeList
    self.rootitem = root = self._MakeRoot()
  File "C:\Python310\Lib\site-packages\pythonwin\pywin\framework\editor\", line 153, in _MakeRoot
    data = reader(mod, path and [path])
  File "C:\Python310\lib\", line 120, in readmodule_ex
    return _readmodule(module, path or [])
  File "C:\Python310\lib\", line 159, in _readmodule
    return _readmodule(submodule, parent['__path__'], package)
  File "C:\Python310\lib\", line 184, in _readmodule
    return _create_tree(fullmodule, path, fname, source, tree, inpackage)
  File "C:\Python310\lib\", line 272, in _create_tree
  File "C:\Python310\lib\", line 410, in visit
    return visitor(node)
  File "C:\Python310\lib\", line 418, in generic_visit
  File "C:\Python310\lib\", line 410, in visit
    return visitor(node)
  File "C:\Python310\lib\", line 243, in visit_Import
    _readmodule(, [])
  File "C:\Python310\lib\", line 167, in _readmodule
    spec = importlib.util._find_spec_from_path(fullmodule, search_path)
  File "C:\Python310\lib\importlib\", line 69, in _find_spec_from_path
    raise ValueError('{}.__spec__ is None'.format(name))
ValueError: __main__.__spec__ is None
Date User Action Args
2021-02-22 17:48:25kxrobsetrecipients: + kxrob
2021-02-22 17:48:25kxrobsetmessageid: <>
2021-02-22 17:48:25kxroblinkissue43299 messages
2021-02-22 17:48:25kxrobcreate