New submission from Renaud Blanch <rndbl...@gmail.com>:

The TypeError message is erroneous when attempting to format a non number 
object with a '%i' string (notice the '%d' in the error message):

    >>> '%i' % 's'
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: %d format: a number is required, not str

This is because PyUnicode_Format aliases i to d for the formatting handling, 
but this has the side effect of performing the substitution in the error 
message too.

The attached patch (against 3.3, but this behaviour has been there since 2.6) 
suppress the side effect and corrects the error message.

----------
components: Interpreter Core
files: PyUnicode_Format_TypeError_message.patch
keywords: patch
messages: 139607
nosy: rndblnch
priority: normal
severity: normal
status: open
title: wrong TypeError message on '%i' formatting
type: behavior
versions: Python 3.3
Added file: 
http://bugs.python.org/file22542/PyUnicode_Format_TypeError_message.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12471>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to