From: <pj...@us...> - 2010-04-06 02:02:54
|
Revision: 7002 http://jython.svn.sourceforge.net/jython/?rev=7002&view=rev Author: pjenvey Date: 2010-04-06 02:02:34 +0000 (Tue, 06 Apr 2010) Log Message: ----------- better fix for r7001, also fixes unicode-escape not escaping the escape char fixes #1502 patch from gz Modified Paths: -------------- trunk/jython/Lib/test/test_codecs_jy.py trunk/jython/src/org/python/core/PyString.java trunk/jython/src/org/python/modules/_codecs.java Modified: trunk/jython/Lib/test/test_codecs_jy.py =================================================================== --- trunk/jython/Lib/test/test_codecs_jy.py 2010-04-05 01:49:16 UTC (rev 7001) +++ trunk/jython/Lib/test/test_codecs_jy.py 2010-04-06 02:02:34 UTC (rev 7002) @@ -18,6 +18,7 @@ def test_string_escape_1502(self): # http://bugs.jython.org/issue1502 self.assertEqual('\\x00'.encode('string-escape'), '\\\\x00') + self.assertEqual('\\x00'.encode('unicode-escape'), '\\\\x00') def test_main(): Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2010-04-05 01:49:16 UTC (rev 7001) +++ trunk/jython/src/org/python/core/PyString.java 2010-04-06 02:02:34 UTC (rev 7002) @@ -154,7 +154,7 @@ for (int i = 0; size-- > 0; ) { int ch = str.charAt(i++); /* Escape quotes */ - if (use_quotes && (ch == quote || ch == '\\')) { + if ((use_quotes && ch == quote) || ch == '\\') { v.append('\\'); v.append((char) ch); continue; Modified: trunk/jython/src/org/python/modules/_codecs.java =================================================================== --- trunk/jython/src/org/python/modules/_codecs.java 2010-04-05 01:49:16 UTC (rev 7001) +++ trunk/jython/src/org/python/modules/_codecs.java 2010-04-06 02:02:34 UTC (rev 7002) @@ -118,10 +118,7 @@ } public static PyTuple escape_encode(String str, String errors) { - int size = str.length(); - str = PyString.encode_UnicodeEscape(str, true); - // The string will be quoted, unquote - return encode_tuple(str.substring(1, str.length() - 1), size); + return encode_tuple(PyString.encode_UnicodeEscape(str, false), str.length()); } /* --- Character Mapping Codec --------------------------------------- */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |