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.

Title: locale.format gives wrong exception on some erroneous input
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, tdiggins
Priority: normal Keywords:

Created on 2006-01-23 07:46 by tdiggins, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit tdiggins, 2006-01-23 07:46 tests for & implementation of improved errror handling for locale.format
Messages (2)
msg27325 - (view) Author: Tim Diggins (tdiggins) Date: 2006-01-23 07:46
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.
msg27326 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-09-30 10:27
Logged In: YES 

format() has been overhauled in 2.5. This doesn't apply anymore.
Date User Action Args
2022-04-11 14:56:15adminsetgithub: 42823
2006-01-23 07:46:53tdigginscreate