← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-bugs-raw-strings into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-bugs-raw-strings into launchpad:master.

Commit message:
Correct spelling of \-escapes in lp.bugs

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/394403

Use raw strings or double-\, depending on whether it's more convenient for '\n' to mean a newline character or the two characters '\' 'n'.  This fixes a number of DeprecationWarnings with Python >= 3.6.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-bugs-raw-strings into launchpad:master.
diff --git a/lib/lp/bugs/browser/bugtask.py b/lib/lp/bugs/browser/bugtask.py
index 219c9e6..c6bc9d7 100644
--- a/lib/lp/bugs/browser/bugtask.py
+++ b/lib/lp/bugs/browser/bugtask.py
@@ -594,8 +594,8 @@ class BugTaskView(LaunchpadView, BugViewMixin, FeedsMixin):
             'affects|description|security vulnerability|information type|'
             'summary|tags|visibility|bug task deleted')
         bugtask_change_re = (
-            '[a-z0-9][a-z0-9\+\.\-]+( \([A-Za-z0-9\s]+\))?: '
-            '(assignee|importance|milestone|status)')
+            r'[a-z0-9][a-z0-9\+\.\-]+( \([A-Za-z0-9\s]+\))?: '
+            r'(assignee|importance|milestone|status)')
         interesting_match = re.compile(
             "^(%s|%s)$" % (bug_change_re, bugtask_change_re)).match
 
@@ -2467,12 +2467,12 @@ class BugActivityItem:
         # Turn the strings of newvalue and oldvalue into sets so we
         # can work out the differences.
         if self.newvalue != '':
-            new_tags = set(re.split('\s+', self.newvalue))
+            new_tags = set(re.split(r'\s+', self.newvalue))
         else:
             new_tags = set()
 
         if self.oldvalue != '':
-            old_tags = set(re.split('\s+', self.oldvalue))
+            old_tags = set(re.split(r'\s+', self.oldvalue))
         else:
             old_tags = set()
 
diff --git a/lib/lp/bugs/browser/tests/test_bug_views.py b/lib/lp/bugs/browser/tests/test_bug_views.py
index 149bf51..9382821 100644
--- a/lib/lp/bugs/browser/tests/test_bug_views.py
+++ b/lib/lp/bugs/browser/tests/test_bug_views.py
@@ -609,7 +609,7 @@ class TestBugTextViewPrivateTeams(TestCaseWithFactory):
         self.assertIn(
             "assignee: %s" % assignee.unique_displayname, view_text)
         self.assertTextMatchesExpressionIgnoreWhitespace(
-            "subscribers:\n.*%s \(%s\)"
+            "subscribers:\n.*%s \\(%s\\)"
             % (naked_subscriber.displayname, naked_subscriber.name),
             view_text)
 
diff --git a/lib/lp/bugs/browser/tests/test_bugattachment_file_access.py b/lib/lp/bugs/browser/tests/test_bugattachment_file_access.py
index 8a967c8..81c4f0e 100644
--- a/lib/lp/bugs/browser/tests/test_bugattachment_file_access.py
+++ b/lib/lp/bugs/browser/tests/test_bugattachment_file_access.py
@@ -82,7 +82,7 @@ class TestAccessToBugAttachmentFiles(TestCaseWithFactory):
         navigation = BugAttachmentFileNavigation(
             self.bugattachment, request)
         view = navigation.publishTraverse(request, '+files')
-        mo = re.match('^http://.*/\d+/foo.txt$', view.target)
+        mo = re.match(r'^http://.*/\d+/foo.txt$', view.target)
         self.assertIsNot(None, mo)
 
     def test_access_to_restricted_file(self):
@@ -99,7 +99,7 @@ class TestAccessToBugAttachmentFiles(TestCaseWithFactory):
         navigation = BugAttachmentFileNavigation(self.bugattachment, request)
         view = navigation.publishTraverse(request, '+files')
         mo = re.match(
-            '^https://.*.restricted.*/\d+/foo.txt\?token=.*$', view.target)
+            r'^https://.*.restricted.*/\d+/foo.txt\?token=.*$', view.target)
         self.assertIsNot(None, mo)
 
     def test_access_to_restricted_file_unauthorized(self):
diff --git a/lib/lp/bugs/browser/tests/test_bugnomination.py b/lib/lp/bugs/browser/tests/test_bugnomination.py
index 36ffd0a..caab93f 100644
--- a/lib/lp/bugs/browser/tests/test_bugnomination.py
+++ b/lib/lp/bugs/browser/tests/test_bugnomination.py
@@ -180,7 +180,7 @@ class TestBugEditLinks(TestCaseWithFactory):
         soupmatchers.Tag(
             'Edit link', 'a',
             attrs={'class': 'assignee-edit',
-                   'href': re.compile('\+editstatus$')}))
+                   'href': re.compile(r'\+editstatus$')}))
 
     def _createBug(self, bug_task_number=1):
         series = self.factory.makeProductSeries()
diff --git a/lib/lp/bugs/model/bugactivity.py b/lib/lp/bugs/model/bugactivity.py
index d3f5cfa..7422668 100644
--- a/lib/lp/bugs/model/bugactivity.py
+++ b/lib/lp/bugs/model/bugactivity.py
@@ -56,8 +56,8 @@ class BugActivity(SQLBase):
 
     # The regular expression we use for matching bug task changes.
     bugtask_change_re = re.compile(
-        '(?P<target>[a-z0-9][a-z0-9\+\.\-]+( \([A-Za-z0-9\s]+\))?): '
-        '(?P<attribute>assignee|importance|milestone|status)')
+        r'(?P<target>[a-z0-9][a-z0-9\+\.\-]+( \([A-Za-z0-9\s]+\))?): '
+        r'(?P<attribute>assignee|importance|milestone|status)')
 
     @property
     def target(self):
diff --git a/lib/lp/bugs/model/bugwatch.py b/lib/lp/bugs/model/bugwatch.py
index 3336576..b21ea5d 100644
--- a/lib/lp/bugs/model/bugwatch.py
+++ b/lib/lp/bugs/model/bugwatch.py
@@ -595,7 +595,7 @@ class BugWatchSet:
         # * /tracker/(index.php) (index.php part is optional)
         # * /tracker2/(index.php) (index.php part is optional)
         sf_path_re = re.compile(
-            '^\/(support\/tracker\.php|tracker2?\/(index\.php)?)$')
+            r'^\/(support\/tracker\.php|tracker2?\/(index\.php)?)$')
         if (sf_path_re.match(path) is None):
             return None
         if not query.get('aid'):
@@ -682,7 +682,7 @@ class BugWatchSet:
             return None
 
         google_code_url_expression = re.compile(
-            "(?P<base_path>\/p\/[a-z][-a-z0-9]+/issues)/detail")
+            r"(?P<base_path>\/p\/[a-z][-a-z0-9]+/issues)/detail")
 
         path_match = google_code_url_expression.match(path)
         if path_match is None:
diff --git a/lib/lp/bugs/tests/test_bugwatch.py b/lib/lp/bugs/tests/test_bugwatch.py
index 50996b5..73a2108 100644
--- a/lib/lp/bugs/tests/test_bugwatch.py
+++ b/lib/lp/bugs/tests/test_bugwatch.py
@@ -337,7 +337,7 @@ class EmailAddressExtractBugTrackerAndBugTest(ExtractBugTrackerAndBugTest):
         # addresses.
         self.assertRaises(UnrecognizedBugTrackerURL,
             self.bugwatch_set.extractBugTrackerAndBug,
-            url='this\.is@@a.bad.email.address')
+            url=r'this\.is@@a.bad.email.address')
 
     def test_invalid_bug_number(self):
         # Test does not make sense for email addresses.