classification
Title: Typo in error message
Type: behavior Stage: commit review
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: Marc.Abramowitz, brett.cannon, ezio.melotti, jcea, nedbat, python-dev
Priority: normal Keywords: easy, patch

Created on 2012-07-05 18:57 by Marc.Abramowitz, last changed 2012-07-09 17:25 by brett.cannon. This issue is now closed.

Files
File name Uploaded Description Edit
python_issue_15256.patch Marc.Abramowitz, 2012-07-06 18:30 review
python_issue_15256.patch Marc.Abramowitz, 2012-07-06 20:33 review
Messages (7)
msg164693 - (view) Author: Marc Abramowitz (Marc.Abramowitz) * Date: 2012-07-05 18:57
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?
msg164740 - (view) Author: Marc Abramowitz (Marc.Abramowitz) * Date: 2012-07-06 17:33
I think this is just a simple typo and a consistency issue; not a grammatical issue.

The misspelled version was added in a recent commit:

[last: 0] marca@SCML-MarcA:~/dev/hg-repos/cpython$ hg log -r 76455
changeset:   76455:085cf1480cfe
user:        Brett Cannon <brett@python.org>
date:        Sat Apr 21 21:09:46 2012 -0400
summary:     Issue #13959: Re-implement imp.find_module() in Lib/imp.py.

Link to issue: http://bugs.python.org/issue13959
msg164744 - (view) Author: Marc Abramowitz (Marc.Abramowitz) * Date: 2012-07-06 18:30
Attaching patch
msg164754 - (view) Author: Marc Abramowitz (Marc.Abramowitz) * Date: 2012-07-06 20:33
Patch with Brett's comments
msg164960 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-07-08 01:44
Patch looks fine. Next time I have python-dev time I will commit it.
msg165097 - (view) Author: Roundup Robot (python-dev) Date: 2012-07-09 17:24
New changeset 75831951a6b5 by Brett Cannon in branch 'default':
Issue #15256: Re-use the ImportError exception message as defined by
http://hg.python.org/cpython/rev/75831951a6b5
msg165098 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-07-09 17:25
Thanks for the patch, Marc!
History
Date User Action Args
2012-07-09 17:25:04brett.cannonsetstatus: open -> closed
resolution: fixed
messages: + msg165098
2012-07-09 17:24:43python-devsetnosy: + python-dev
messages: + msg165097
2012-07-08 01:44:53brett.cannonsetassignee: brett.cannon
messages: + msg164960
stage: patch review -> commit review
2012-07-07 02:32:03terry.reedysetstage: needs patch -> patch review
2012-07-06 20:33:53Marc.Abramowitzsetfiles: + python_issue_15256.patch

messages: + msg164754
2012-07-06 18:30:09Marc.Abramowitzsetfiles: + python_issue_15256.patch
keywords: + patch
messages: + msg164744
2012-07-06 17:40:35ezio.melottisetkeywords: + easy
nosy: + ezio.melotti

stage: needs patch
2012-07-06 17:33:04Marc.Abramowitzsetmessages: + msg164740
2012-07-06 17:11:25jceasetnosy: + jcea
2012-07-05 19:00:11nedbatsetnosy: + nedbat
2012-07-05 18:57:48Marc.Abramowitzcreate