Gary Poster has proposed merging lp:~gary/launchpad/bug683115 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #683115 ValueError raised getting length of batch results
  https://bugs.launchpad.net/bugs/683115


Deploying the previous branch for this bug showed that my diagnosis was 
correct.  Discussion with Curtis indicated that it should not be unexpected for 
Google to give us an approximate total of less than zero, and that treating 
numbers less than zero as zero should be fine.  Therefore, this branch does 
that, simply, removing the error that I raised in my last branch.

Lint is happy, and the Google integration tests are too.
-- 
https://code.launchpad.net/~gary/launchpad/bug683115/+merge/43572
Your team Launchpad code reviewers is requested to review the proposed merge of 
lp:~gary/launchpad/bug683115 into lp:launchpad.
=== modified file 'lib/canonical/launchpad/doc/google-searchservice.txt'
--- lib/canonical/launchpad/doc/google-searchservice.txt	2010-11-30 23:01:42 +0000
+++ lib/canonical/launchpad/doc/google-searchservice.txt	2010-12-13 20:49:03 +0000
@@ -295,8 +295,8 @@
     GoogleWrongGSPVersion: Could not get the 'total' from the
                            GSP XML response.
 
-Similarly, if the total were ever less than zero (which we are suspicious
-of because of bug 683115), we would see an error.
+On the other hand, if the total is ever less than zero (see bug 683115),
+this is expected: we simply return a total of 0.
 
     >>> gsp_xml_file_name = path.join(
     ...     base_path, 'googlesearchservice-negative-total.xml')
@@ -308,11 +308,8 @@
     <RES SN="1" EN="1">
     <M>-1</M>...
 
-    >>> google_search._parse_google_search_protocol(gsp_xml)
-    Traceback (most recent call last):
-     ...
-    GoogleResponseError: The reported total (-1, from '-1') was less than
-                zero. See bug 683115.
+    >>> google_search._parse_google_search_protocol(gsp_xml).total
+    0
 
 A PageMatch requires a title, url, and a summary. If those elements
 ('<T>', '<U>', '<S>') cannot be found nested in an '<R>' a PageMatch

=== modified file 'lib/canonical/launchpad/utilities/searchservice.py'
--- lib/canonical/launchpad/utilities/searchservice.py	2010-11-30 23:06:43 +0000
+++ lib/canonical/launchpad/utilities/searchservice.py	2010-12-13 20:49:03 +0000
@@ -290,9 +290,8 @@
             raise GoogleWrongGSPVersion(
                 "Could not get the 'total' from the GSP XML response.")
         if total < 0:
-            raise GoogleResponseError(
-                ("The reported total (%d, from %r) was less than zero. "
-                 "See bug 683115.") % (total, results.find('M').text))
+            # See bug 683115.
+            total = 0
         for result in results.findall('R'):
             url_tag = result.find('U')
             title_tag = result.find('T')

_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to