1. Oscar Campos
  2. rope

Commits

Ali Gholami Rudi  committed 873bec5

codeanalyze: handling escaped strings

  • Participants
  • Parent commits a4dc6e8
  • Branches trunk

Comments (0)

Files changed (2)

File rope/base/codeanalyze.py

View file
     def _find_string_start(self, offset):
         kind = self.source[offset]
         offset -= 1
-        while self.source[offset] != kind:
+        while offset > 0:
+            if self.source[offset] == kind and \
+                    (offset == 0 or self.source[offset - 1] != '\\'):
+                break
             offset -= 1
         return offset
 

File ropetest/codeanalyzetest.py

View file
         result = self._find_primary(code, len(code) - 2)
         self.assertEquals('(b + c).d[0]()', result)
 
+    def test_getting_primary_and_strings_at_the_end_of_line(self):
+        code = 'f(\'\\\'\')\n'
+        result = self._find_primary(code, len(code) - 1)
+
     # XXX: not crossing new lines
     def xxx_test_getting_primary_and_not_crossing_newlines(self):
         code = '\na = (b + c)\n(4 + 1).x\n'