New submission from Jayanth Raman <raman.jaya...@gmail.com>:

With file xx.py:

class Foo(object):
    def __init__(self, x):
        self.x = x
    def __long__(self):
        return long(self.x)
    def __float__(self):
        return float(self.x)
y = Foo(22)
print '%d' % y
print '%d' % y


Interactive mode:

$ python -V
Python 2.6.7
$ python -i xx.py
22
22
>>>
TypeError: int() argument must be a string or a number, not 'Foo'
>>> '%d' % y
'22'
>>> '%d' % y
TypeError: int() argument must be a string or a number, not 'Foo'
>>> '%d' % y
'22'
>>> '%d' % y
TypeError: int() argument must be a string or a number, not 'Foo'

It alternates between printing '22' and print a TypeError message.  Expected it 
to be consistent.

Also, the first carraige-return (with no input) results in an error message.  
Did not expect an error message.  In fact, typing pretty much anything (e.g. an 
undefined variable or raise(Exception())) results in the same error message.

On Mac OS X Darwin Kernel Version 10.8.0
Python 2.6.7 (r267:88850, Jul  6 2011, 13:57:37) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin

Thanks.

----------
assignee: ronaldoussoren
components: Macintosh
messages: 147711
nosy: jayanth, ronaldoussoren
priority: normal
severity: normal
status: open
title: String formatting bug in interactive mode
type: behavior
versions: Python 2.6

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

Reply via email to