[pypy-svn] r47425 - in pypy/dist/pypy/objspace/std: . test
arigo at codespeak.net
arigo at codespeak.net
Sat Oct 13 12:41:51 CEST 2007
Author: arigo
Date: Sat Oct 13 12:41:50 2007
New Revision: 47425
Modified:
pypy/dist/pypy/objspace/std/formatting.py
pypy/dist/pypy/objspace/std/test/test_stringformat.py
Log:
Fix another XXX.
Modified: pypy/dist/pypy/objspace/std/formatting.py
==============================================================================
--- pypy/dist/pypy/objspace/std/formatting.py (original)
+++ pypy/dist/pypy/objspace/std/formatting.py Sat Oct 13 12:41:50 2007
@@ -394,9 +394,11 @@
else:
n = space.int_w(w_value)
if do_unicode:
- c = unichr(n)
- # XXX no range checking, but our unichr() builtin needs
- # to be fixed too
+ try:
+ c = unichr(n)
+ except ValueError:
+ raise OperationError(space.w_OverflowError,
+ space.wrap("unicode character code out of range"))
self.std_wp([c])
else:
try:
Modified: pypy/dist/pypy/objspace/std/test/test_stringformat.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_stringformat.py (original)
+++ pypy/dist/pypy/objspace/std/test/test_stringformat.py Sat Oct 13 12:41:50 2007
@@ -131,10 +131,12 @@
raises(ValueError, '%('.__mod__, ({},))
def test_format_char(self):
+ import sys
assert '%c' % 65 == 'A'
assert '%c' % 'e' == 'e'
raises(OverflowError, '%c'.__mod__, (256,))
raises(OverflowError, '%c'.__mod__, (-1,))
+ raises(OverflowError, u'%c'.__mod__, (sys.maxunicode+1,))
raises(TypeError, '%c'.__mod__, ("bla",))
raises(TypeError, '%c'.__mod__, ("",))
raises(TypeError, '%c'.__mod__, (['c'],))
More information about the Pypy-commit
mailing list