[pypy-svn] r5022 - in pypy/trunk/src/pypy/objspace/std: . test
mwh at codespeak.net
mwh at codespeak.net
Thu Jun 10 12:10:13 CEST 2004
Author: mwh
Date: Thu Jun 10 12:10:12 2004
New Revision: 5022
Modified:
pypy/trunk/src/pypy/objspace/std/stringobject.py
pypy/trunk/src/pypy/objspace/std/test/test_stringformat.py
Log:
"unclear behaviour requirement" my ass!
i'm not sure how sensible the fix is, though
where is everyone?
Modified: pypy/trunk/src/pypy/objspace/std/stringobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/stringobject.py (original)
+++ pypy/trunk/src/pypy/objspace/std/stringobject.py Thu Jun 10 12:10:12 2004
@@ -1012,7 +1012,11 @@
if c=='s':
pieces.append(str(value))
elif c=='d':
- pieces.append(str(int(value)))
+ try:
+ inter = value.__int__
+ except AttributeError:
+ raise TypeError, "an integer argument is required"
+ pieces.append(str(inter()))
elif c=='x':
pieces.append(hex(int(value)))
elif c=='r':
Modified: pypy/trunk/src/pypy/objspace/std/test/test_stringformat.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/test/test_stringformat.py (original)
+++ pypy/trunk/src/pypy/objspace/std/test/test_stringformat.py Thu Jun 10 12:10:12 2004
@@ -64,10 +64,7 @@
def test_format_string(self):
self.assertEquals('23', '%s' % '23')
self.assertEquals("'23'", '%r' % '23')
- """ unclear behavior requirement, so, both commented for now...:
- self.assertEquals('23', '%d' % '23') ...or...:
- self.assertRaises(TypeError, '%d'.__mod__, ((23,),)) ...?
- """
+ self.assertRaises(TypeError, '%d'.__mod__, "23")
def test_format_float(self):
self.assertEquals('23', '%d' % 23.456)
More information about the Pypy-commit
mailing list