From: <pj...@us...> - 2008-08-22 20:17:02
|
Revision: 5234 http://jython.svn.sourceforge.net/jython/?rev=5234&view=rev Author: pjenvey Date: 2008-08-22 20:16:59 +0000 (Fri, 22 Aug 2008) Log Message: ----------- fix unicode __add__ and repeat always forcing the basic plane on the result -- can't optimize for strs when unicode also uses these methods Modified Paths: -------------- trunk/jython/src/org/python/core/PyString.java Added Paths: ----------- trunk/jython/Lib/test/test_unicode_jy.py Added: trunk/jython/Lib/test/test_unicode_jy.py =================================================================== --- trunk/jython/Lib/test/test_unicode_jy.py (rev 0) +++ trunk/jython/Lib/test/test_unicode_jy.py 2008-08-22 20:16:59 UTC (rev 5234) @@ -0,0 +1,28 @@ +"""Misc unicode tests + +Made for Jython. +""" +import re +import unittest +from test import test_support + +class UnicodeTestCase(unittest.TestCase): + + def test_simplejson_plane_bug(self): + # a bug exposed by simplejson: unicode __add__ was always + # forcing the basic plane + chunker = re.compile(r'(.*?)(["\\\x00-\x1f])', re.VERBOSE | re.MULTILINE | re.DOTALL) + orig = u'z\U0001d120x' + quoted1 = u'"z\U0001d120x"' + quoted2 = '"' + orig + '"' + # chunker re gives different results depending on the plane + self.assertEqual(chunker.match(quoted1, 1).groups(), (orig, u'"')) + self.assertEqual(chunker.match(quoted2, 1).groups(), (orig, u'"')) + + +def test_main(): + test_support.run_unittest(UnicodeTestCase) + + +if __name__ == "__main__": + test_main() Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2008-08-22 15:31:56 UTC (rev 5233) +++ trunk/jython/src/org/python/core/PyString.java 2008-08-22 20:16:59 UTC (rev 5234) @@ -670,7 +670,7 @@ for(int i = 0; i < count; i++) { string.getChars(0, s, new_chars, i * s); } - return createInstance(new String(new_chars), true); + return createInstance(new String(new_chars)); } @Override @@ -711,7 +711,7 @@ if (generic_other instanceof PyUnicode) { return new PyUnicode(result); } - return createInstance(result, true); + return createInstance(result); } else return null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |