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: Use repr(module name) ImportErrors
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.3
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: brian.curtin, cool-RR, eric.araujo, eric.snow
Priority: normal Keywords:

Created on 2011-11-22 20:28 by cool-RR, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg148140 - (view) Author: Ram Rachum (cool-RR) * Date: 2011-11-22 20:28
Recently I was confronted with a mysterious error:

    ImportError: No module named datetime

Firther investigation revealed that the cause was a pickling problem that ran `__import__('datetime\r')`.

If `ImportError` would have shown the module name as a string, there would be no ambiguity:

    ImportError: No module named 'datetime\r'
msg148141 - (view) Author: Brian Curtin (brian.curtin) * (Python committer) Date: 2011-11-22 20:32
3.3 will be adding an attribute which would have "datetime\r" here. See #1559549, which might make this a duplicate.

You shouldn't (have to) rely on parsing the exception string.
msg148401 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-11-26 13:24
__import__ and importlib in Python 3.3 already use repr (see c4361bab6914 and 9f9b7b656761):

  Traceback (most recent call last):
    File "<string>", line 1, in <module>
  ImportError: No module named 'string\n'

For other stdlib modules, see #8754.
History
Date User Action Args
2022-04-11 14:57:24adminsetgithub: 57666
2011-11-27 00:11:53eric.snowsetnosy: + eric.snow
2011-11-26 13:24:08eric.araujosetnosy: + eric.araujo
title: Display module name as string in `ImportError` -> Use repr(module name) ImportErrors
messages: + msg148401

resolution: out of date
stage: resolved
2011-11-22 20:34:14cool-RRsetstatus: open -> closed
2011-11-22 20:32:22brian.curtinsetnosy: + brian.curtin
messages: + msg148141
2011-11-22 20:29:04cool-RRsettype: behavior
2011-11-22 20:28:55cool-RRcreate