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: error about string formatting rewording?
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: anthonybaxter, dyoo, rhettinger
Priority: normal Keywords: patch

Created on 2002-04-26 17:24 by dyoo, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python-formatting.diff dyoo, 2002-04-28 03:39 Modifies the error message to explicitely mention "string formatting".
Messages (5)
msg39718 - (view) Author: Danny Yoo (dyoo) Date: 2002-04-26 17:24
The error message that occurs during string formatting,
when one passes more arguments than necessary, is this:

    TypeError: not all arguments converted

It might be good to mention that this conversion is
taking place as a result of string formatting.  My
suggestions is to add a little more to this message:

    TypeError: not all arguments converted during
string formatting


The reason is because string formatting uses the same
operation as the modulus command, and also can take in
a single integer argument, like:

   ziffer = note % 10

Newcomers to the language often mix up string and
numbers, and the error message above can be very
cryptic if one doesn't know about string formatting
yet.  With the reworded error message, there's less of
chance of confusion.

See:

http://mail.python.org/pipermail/tutor/2002-April/014110.html

for more details on why this might be nice.  Thanks!
msg39719 - (view) Author: Danny Yoo (dyoo) Date: 2002-04-28 03:39
Logged In: YES 
user_id=49843

Ok, I wrote up a patch to add more to the error message. 
Here's what it does:

>>> def isEven(n): return n % 2 == 0
... 
>>> isEven(17)
False
>>> isEven("17")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<stdin>", line 1, in isEven
TypeError: not all arguments converted during string formatting
msg39720 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-05-13 05:05
Logged In: YES 
user_id=80475

Martin, is this okay to commit to MAIN and to backport to 
release22-maint?

Review:
-----------------------
This makes sense to me.
The code runs fine.

I grepped the objects directory and found that all 
instances of the message had been accounted for.

Read the original email from an instructor and believe that 
the current error message was confusing to students.
msg39721 - (view) Author: Anthony Baxter (anthonybaxter) (Python triager) Date: 2002-05-13 05:13
Logged In: YES 
user_id=29957

This seems fine to me, and is suitable for the 22 branch.
The 21 branch is mostly only getting genuine bugs, rather
than cosmetic fixes. I can't imagine anything would depend
on the wording of the error messages...
msg39722 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2002-05-21 15:17
Logged In: YES 
user_id=80475

Committed as stringobject.c 2.163 and unicodeobject.c 2.148.
Only put in Py2.3, left-out of release22-maint.
Closing patch.
History
Date User Action Args
2022-04-10 16:05:16adminsetgithub: 36507
2002-04-26 17:24:20dyoocreate