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.

Author Marc.Abramowitz
Recipients Marc.Abramowitz, brett.cannon
Date 2012-07-05.18:57:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1341514669.16.0.587932473822.issue15256@psf.upfronthosting.co.za>
In-reply-to
Content
From a failing unit test with coverage.py, I noticed what seems to be a slight typo in the error message when a module cannot be imported:

diff -r 1186d68715cc Lib/imp.py
--- a/Lib/imp.py	Wed Jul 04 19:33:45 2012 -0700
+++ b/Lib/imp.py	Thu Jul 05 11:50:25 2012 -0700
@@ -230,7 +230,7 @@
                 continue
             break  # Break out of outer loop when breaking out of inner loop.
     else:
-        raise ImportError('No module name {!r}'.format(name), name=name)
+        raise ImportError('No module named {!r}'.format(name), name=name)
 
     encoding = None
     if mode == 'U':

Note the missing "d". This makes it match similar existing error messages:

Lib/importlib/_bootstrap.py
1238:_ERR_MSG = 'No module named {!r}'

Lib/modulefinder.py
185:        self.msgout(4, "raise ImportError: No module named", qname)
186:        raise ImportError("No module named " + qname)
198:                self.msgout(4, "raise ImportError: No module named", mname)
199:                raise ImportError("No module named " + mname)
215:                    raise ImportError("No module named " + subname)

Lib/runpy.py
106:        raise ImportError("No module named %s" % mod_name)

I wonder if this can be centralized to ensure that all code uses the exact same message?
History
Date User Action Args
2012-07-05 18:57:49Marc.Abramowitzsetrecipients: + Marc.Abramowitz, brett.cannon
2012-07-05 18:57:49Marc.Abramowitzsetmessageid: <1341514669.16.0.587932473822.issue15256@psf.upfronthosting.co.za>
2012-07-05 18:57:48Marc.Abramowitzlinkissue15256 messages
2012-07-05 18:57:47Marc.Abramowitzcreate