[Patches] [ python-Patches-549187 ] error about string formatting rewording?

noreply@sourceforge.net noreply@sourceforge.net
Tue, 21 May 2002 08:17:42 -0700


Patches item #549187, was opened at 2002-04-26 12:24
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=549187&group_id=5470

Category: Core (C code)
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Danny Yoo (dyoo)
>Assigned to: Raymond Hettinger (rhettinger)
Summary: error about string formatting rewording?

Initial Comment:
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!

----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2002-05-21 10:17

Message:
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.

----------------------------------------------------------------------

Comment By: Anthony Baxter (anthonybaxter)
Date: 2002-05-13 00:13

Message:
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...

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2002-05-13 00:05

Message:
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.

----------------------------------------------------------------------

Comment By: Danny Yoo (dyoo)
Date: 2002-04-27 22:39

Message:
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

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=549187&group_id=5470