Index: src/org/python/core/PyString.java =================================================================== --- src/org/python/core/PyString.java (revision 3451) +++ src/org/python/core/PyString.java (working copy) @@ -4048,6 +4048,11 @@ PyInteger val; try { val = (PyInteger)arg.__int__(); + if(val.getValue() < 0) + throw Py.OverflowError("unsigned byte integer is less than minimum"); + else if(val.getValue() > 255) + throw Py.OverflowError("unsigned byte integer is greater than maximum"); + } catch(PyException e){ if(Py.matchException(e, Py.AttributeError)) { throw Py.TypeError("%c requires int or char"); Index: Lib/test/string_tests.py =================================================================== --- Lib/test/string_tests.py (revision 3451) +++ Lib/test/string_tests.py (working copy) @@ -546,12 +546,9 @@ self.checkequal('$', "%c", '__mod__', 36) self.checkequal('10', "%d", '__mod__', 10) self.checkequal('\x7f', "%c", '__mod__', 0x7f) -# Jython transition 2.3 -# values outside of the size of a single char aren't prohibited in formatting %c -# http://jython.org/bugs/1768075 -# for ordinal in (-100, 0x200000): - # unicode raises ValueError, str raises OverflowError -# self.checkraises((ValueError, OverflowError), '%c', '__mod__', ordinal) + + for ordinal in (-100, 0x200000): + self.checkraises((ValueError, OverflowError), '%c', '__mod__', ordinal) self.checkequal(' 42', '%3ld', '__mod__', 42) self.checkequal('0042.00', '%07.2f', '__mod__', 42) Index: Lib/test/test_str.py =================================================================== --- Lib/test/test_str.py (revision 3451) +++ Lib/test/test_str.py (working copy) @@ -16,10 +16,7 @@ def test_formatting(self): string_tests.MixinStrUnicodeUserStringTest.test_formatting(self) -# Jython transition 2.3 -# values outside of the size of a single char aren't prohibited in formatting %c -# http://jython.org/bugs/1768075 -# self.assertRaises(OverflowError, '%c'.__mod__, 0x1234) + self.assertRaises(OverflowError, '%c'.__mod__, 0x1234) def test_main(): test_support.run_unittest(StrTest)