Rev 96: Found a bug in the scanner, it was escaping but not printing control chars. in http://bazaar.launchpad.net/~meliae-dev/meliae/trunk

John Arbash Meinel john at arbash-meinel.com
Tue Oct 13 22:27:00 BST 2009


At http://bazaar.launchpad.net/~meliae-dev/meliae/trunk

------------------------------------------------------------
revno: 96
revision-id: john at arbash-meinel.com-20091013212654-ed3tsixj3aosu0rc
parent: john at arbash-meinel.com-20091013211824-rdre3myut4f3mole
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: trunk
timestamp: Tue 2009-10-13 16:26:54 -0500
message:
  Found a bug in the scanner, it was escaping but not printing control chars.
-------------- next part --------------
=== modified file 'meliae/_scanner_core.c'
--- a/meliae/_scanner_core.c	2009-10-07 21:39:53 +0000
+++ b/meliae/_scanner_core.c	2009-10-13 21:26:54 +0000
@@ -268,7 +268,7 @@
                             ((unsigned short)c & 0xFF));
         } else if (c == '\\' || c == '/' || c == '"') {
             *ptr++ = '\\';
-            *ptr++ = 'c';
+            *ptr++ = c;
         } else {
             *ptr++ = c;
         }

=== modified file 'meliae/tests/test__scanner.py'
--- a/meliae/tests/test__scanner.py	2009-09-18 17:00:34 +0000
+++ b/meliae/tests/test__scanner.py	2009-10-13 21:26:54 +0000
@@ -295,6 +295,12 @@
             ', "value": "a string", "refs": []}\n'
             % (id(mystr), _scanner.size_of(mystr)),
             mystr)
+        mystr = 'a \\str/with"control'
+        self.assertDumpText(
+            '{"address": %d, "type": "str", "size": %d, "len": 19'
+            ', "value": "a \\\\str\\/with\\"control", "refs": []}\n'
+            % (id(mystr), _scanner.size_of(mystr)),
+            mystr)
 
     def test_unicode(self):
         myu = u'a \xb5nicode'
@@ -394,6 +400,7 @@
 
     def test_str(self):
         self.assertDumpInfo('this is a short \x00 \x1f \xffstring\n')
+        self.assertDumpInfo('a \\string / with " control chars')
 
     def test_long_str(self):
         self.assertDumpInfo('abcd'*1000)



More information about the bazaar-commits mailing list