This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Confusing error message when hook module cannot be loaded
Type: behavior Stage: resolved
Components: Distutils2 Versions:
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: alexis, cournape, eric.araujo, tarek
Priority: normal Keywords:

Created on 2011-03-15 05:44 by cournape, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg130958 - (view) Author: cournapeau david (cournape) Date: 2011-03-15 05:44
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))
msg131779 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-03-22 21:12
It’s strange because we do have tests for the function.  Can you look at them and find any error?
msg145954 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-10-19 20:18
Maybe your bug was #11637, or one of the other bugs that I fixed in 1405df4a1535.  Your simple example now works.
History
Date User Action Args
2022-04-11 14:57:14adminsetgithub: 55761
2011-10-19 20:18:42eric.araujosetstatus: open -> closed
type: crash -> behavior
messages: + msg145954

assignee: tarek -> eric.araujo
resolution: out of date
stage: resolved
2011-03-22 21:12:29eric.araujosetnosy: tarek, eric.araujo, alexis, cournape
messages: + msg131779
2011-03-15 05:44:43cournapecreate