[ python-Bugs-1412580 ] locale.format gives wrong exception on some erroneous input

SourceForge.net noreply at sourceforge.net
Mon Jan 23 08:46:53 CET 2006


Bugs item #1412580, was opened at 2006-01-23 07:46
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1412580&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Tim Diggins (tdiggins)
Assigned to: Nobody/Anonymous (nobody)
Summary: locale.format gives wrong exception on some erroneous input

Initial Comment:
using '2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310
32 bit (Intel)]' on WinXpPro SP2


locale.format(formatString, val, grouping) when passed
a formatString of the wrong type, ought to raise a
TypeError (as some erroneous input does)

Example: locale.format(2.3, 2.3) passes through
AttributeError ("float has no  attribute 'split'").

I thought perhaps the body of the method should be
wrapped in a try:except block, and if any error is
caught, then the arguments should be rigorously tested
for type and lucid exceptions raised. See attachment
for suggestion (with tests).

I'm not clear whether if the format string is erroneous
(bad syntax, or has too many/no %-s, the raised error
should be ValueError (contractually correct) or 
conceivably whatever StringInterpolation raises
(parallelism). I've put tests for both in - currently
ValueError wins.

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1412580&group_id=5470


More information about the Python-bugs-list mailing list