[pypy-svn] r43296 - in pypy/branch/pypy-string-formatting/objspace/std: . test
arigo at codespeak.net
arigo at codespeak.net
Sat May 12 15:24:27 CEST 2007
Author: arigo
Date: Sat May 12 15:24:27 2007
New Revision: 43296
Modified:
pypy/branch/pypy-string-formatting/objspace/std/formatting.py
pypy/branch/pypy-string-formatting/objspace/std/test/test_stringformat.py
Log:
Test for typos.
Modified: pypy/branch/pypy-string-formatting/objspace/std/formatting.py
==============================================================================
--- pypy/branch/pypy-string-formatting/objspace/std/formatting.py (original)
+++ pypy/branch/pypy-string-formatting/objspace/std/formatting.py Sat May 12 15:24:27 2007
@@ -285,6 +285,7 @@
return result
def unknown_fmtchar(self):
+ space = self.space
self.fmtpos -= 1
c = self.peekchr()
if do_unicode:
@@ -292,14 +293,13 @@
space.sys.get('getdefaultencoding'))
w_s = space.call_method(space.newunicode([c]),
"encode",
- [w_defaultencoding,
- space.wrap('replace')])
+ w_defaultencoding,
+ space.wrap('replace'))
s = space.str_w(w_s)
else:
s = c
msg = "unsupported format character '%s' (0x%x) at index %d" % (
s, ord(c), self.fmtpos)
- space = self.space
raise OperationError(space.w_ValueError, space.wrap(msg))
def std_wp(self, r):
Modified: pypy/branch/pypy-string-formatting/objspace/std/test/test_stringformat.py
==============================================================================
--- pypy/branch/pypy-string-formatting/objspace/std/test/test_stringformat.py (original)
+++ pypy/branch/pypy-string-formatting/objspace/std/test/test_stringformat.py Sat May 12 15:24:27 2007
@@ -214,3 +214,6 @@
def test_missing_cases(self):
print '%032d' % -123456789012345678901234567890L
assert '%032d' % -123456789012345678901234567890L == '-0123456789012345678901234567890'
+
+ def test_invalid_char(self):
+ raises(ValueError, 'u"%\u1234" % (4,)')
More information about the Pypy-commit
mailing list