Anonymous avatar Anonymous committed fec8d01

Fixed string literal regular expression pattern

Comments (0)

Files changed (3)

rope/base/codeanalyze.py

 
 def get_string_pattern():
     start = r'(\b[uU]?[rR]?)?'
-    return '|'.join([r"%s'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?" % start,
-                     r'%s"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?' % start,
+    return '|'.join([r"%s'''[^'\\]*((\\.|'(?!'')|\\\n)[^'\\]*)*(''')?" % start,
+                     r'%s"""[^"\\]*((\\.|"(?!"")|\\\n)[^"\\]*)*(""")?' % start,
                      r"%s'[^'\\\n]*(\\.[^'\\\n]*)*'?" % start,
                      r'%s"[^"\\\n]*(\\.[^"\\\n]*)*"?' % start])
 

rope/refactor/move.py

         scope = self.old_pyname.get_object().get_scope()
         start = lines.get_line_start(scope.get_start())
         end_line = scope.get_end()
-        for i in range(end_line + 1, lines.length()):
-            if lines.get_line(i).strip() == '':
-                end_line = i
-            else:
-                break
+        while end_line < lines.length() and \
+              lines.get_line(end_line + 1).strip() == '':
+            end_line += 1
         end = min(lines.get_line_end(end_line) + 1, len(pymodule.source_code))
         return start, end
 

ropetest/refactor/movetest.py

             'def f():\n    print(sys.version, os.path)\n',
             self.mod2.read())
 
+    def test_moving_a_global_when_it_is_used_after_a_multiline_str(self):
+        self.mod1.write('def f():\n    pass\ns = """\\\n"""\nr = f()\n')
+        mover = move.create_move(self.project, self.mod1,
+                                 self.mod1.read().index('f()') + 1)
+        self.project.do(mover.get_changes(self.mod2))
+        self.assertEquals(
+            'import mod2\ns = """\\\n"""\nr = mod2.f()\n',
+            self.mod1.read())
+
 
 if __name__ == '__main__':
     unittest.main()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.