[issue11552] Confusing error message when hook module cannot be loaded

cournapeau david report at bugs.python.org
Tue Mar 15 06:44:43 CET 2011


New submission from cournapeau david <cournape at gmail.com>:

The following simple example:

setup.cfg

[global]
setup_hook = hooks.foo

and the following hooks.py file

def foo(content):
    pass


Traceback (most recent call last):
  File "../distutils2/distutils2/pysetup", line 5, in <module>
    main()
  File "/Users/david/src/projects/distutils2/distutils2/run.py", line 486, in main
    return dispatcher()
  File "/Users/david/src/projects/distutils2/distutils2/run.py", line 477, in __call__
    return func(self, self.args)
  File "/Users/david/src/projects/distutils2/distutils2/run.py", line 161, in _run
    dist.parse_config_files()
  File "/Users/david/src/projects/distutils2/distutils2/dist.py", line 317, in parse_config_files
    return self.config.parse_config_files(filenames)
  File "/Users/david/src/projects/distutils2/distutils2/config.py", line 258, in parse_config_files
    self._read_setup_cfg(parser, filename)
  File "/Users/david/src/projects/distutils2/distutils2/config.py", line 120, in _read_setup_cfg
    self.setup_hook = resolve_name(setup_hook)
  File "/Users/david/src/projects/distutils2/distutils2/util.py", line 644, in resolve_name
    raise ImportError(exc)
ImportError: 'str' object has no attribute 'foo'

I don't understand how it works exactly, but the current code cannot work, as ret needs to be a module package after the __import__ (i.e. the codepath following line 632 and later in util.py (resolve_name function))

----------
assignee: tarek
components: Distutils2
messages: 130958
nosy: alexis, cournape, eric.araujo, tarek
priority: normal
severity: normal
status: open
title: Confusing error message when hook module cannot be loaded
type: crash

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11552>
_______________________________________


More information about the Python-bugs-list mailing list