diff -r 81c754c55d41 -r 10d4ad441ba3 Lib/test/test_builtin.py --- a/Lib/test/test_builtin.py Mon Mar 18 16:53:18 2013 -0700 +++ b/Lib/test/test_builtin.py Tue Mar 19 19:13:03 2013 -0700 @@ -1538,7 +1538,6 @@ class DerivedFromStr(str): pass self.assertEqual(format(0, DerivedFromStr('10')), ' 0') - @unittest.skipIf(is_jython, "FIXME #1861: bin not implemented yet.") def test_bin(self): self.assertEqual(bin(0), '0b0') self.assertEqual(bin(1), '0b1') @@ -1548,8 +1547,6 @@ self.assertEqual(bin(-(2**65)), '-0b1' + '0' * 65) self.assertEqual(bin(-(2**65-1)), '-0b' + '1' * 65) - @unittest.skipIf(is_jython, - "FIXME #1861: bytearray not implemented in Jython yet") def test_bytearray_translate(self): x = bytearray("abc") self.assertRaises(ValueError, x.translate, "1", 1) diff -r 81c754c55d41 -r 10d4ad441ba3 src/org/python/core/PyInteger.java --- a/src/org/python/core/PyInteger.java Mon Mar 18 16:53:18 2013 -0700 +++ b/src/org/python/core/PyInteger.java Tue Mar 19 19:13:03 2013 -0700 @@ -1096,14 +1096,28 @@ } if (spec.alternate) { - if (radix == 2) { - strValue = "0b" + strValue; - } else if (radix == 8) { - strValue = "0o" + strValue; - } else if (radix == 16) { - strValue = "0x" + strValue; + String strPrefix = ""; + switch (radix) { + case 2: + strPrefix = "0b"; + break; + case 8: + strPrefix = "0o"; + break; + case 16: + strPrefix = "0x"; + break; + } + + if (strValue.startsWith("-")) { + assert (sign < 0); + if (!strPrefix.equals("")) + strValue = "-" + strPrefix + strValue.substring(1, strValue.length()); + } else { + strValue = strPrefix + strValue; } } + if (spec.type == 'X') { strValue = strValue.toUpperCase(); }