From: <pj...@us...> - 2010-04-05 01:49:24
|
Revision: 7001 http://jython.svn.sourceforge.net/jython/?rev=7001&view=rev Author: pjenvey Date: 2010-04-05 01:49:16 +0000 (Mon, 05 Apr 2010) Log Message: ----------- fix the string-escape codec not escaping the escape char fixes #1502 thanks gz Modified Paths: -------------- trunk/jython/Lib/test/test_codecs_jy.py trunk/jython/NEWS 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-04 18:02:02 UTC (rev 7000) +++ trunk/jython/Lib/test/test_codecs_jy.py 2010-04-05 01:49:16 UTC (rev 7001) @@ -1,19 +1,28 @@ import subprocess import sys -import test_support import unittest +from test import test_support -class AccessBuiltinCodecs(unittest.TestCase): +class CodecsTestCase(unittest.TestCase): + def test_print_sans_lib(self): - '''Encodes and decodes using utf-8 after in an environment without the standard library + """Encodes and decodes using utf-8 after in an environment + without the standard library - Checks that the builtin utf-8 codec is always available: http://bugs.jython.org/issue1458''' + Checks that the builtin utf-8 codec is always available: + http://bugs.jython.org/issue1458""" subprocess.call([sys.executable, "-J-Dpython.cachedir.skip=true", - "-J-Dpython.security.respectJavaAccessibility=false", + "-J-Dpython.security.respectJavaAccessibility=false", test_support.findfile('print_sans_lib.py')]) + def test_string_escape_1502(self): + # http://bugs.jython.org/issue1502 + self.assertEqual('\\x00'.encode('string-escape'), '\\\\x00') + + def test_main(): - test_support.run_unittest(AccessBuiltinCodecs) + test_support.run_unittest(CodecsTestCase) + if __name__ == "__main__": test_main() Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2010-04-04 18:02:02 UTC (rev 7000) +++ trunk/jython/NEWS 2010-04-05 01:49:16 UTC (rev 7001) @@ -23,6 +23,7 @@ - [ 1563 ] unicode() for Java objects working differently in 2.2 and 2.5 - [ 1566 ] os.popen(cmd).read() returns `\r\n` as newline on Windows with Jython 2.5 - [ 1517 ] TypeError: get_referrers + - [ 1502 ] string-escape codec incorrect - Fix runtime issues during exitfuncs triggered via SystemRestart (such as during Django or Pylons development mode reloading) - Fix pickling of collections.defaultdict objects Modified: trunk/jython/src/org/python/modules/_codecs.java =================================================================== --- trunk/jython/src/org/python/modules/_codecs.java 2010-04-04 18:02:02 UTC (rev 7000) +++ trunk/jython/src/org/python/modules/_codecs.java 2010-04-05 01:49:16 UTC (rev 7001) @@ -118,9 +118,10 @@ } public static PyTuple escape_encode(String str, String errors) { - return encode_tuple(PyString.encode_UnicodeEscape(str, false), - str.length()); - + 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); } /* --- Character Mapping Codec --------------------------------------- */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |