Merge branch 'main' into avm99963-monorail

Merged commit 34d8229ae2b51fb1a15bd208e6fe6185c94f6266

GitOrigin-RevId: 7ee0917f93a577e475f8e09526dd144d245593f4
diff --git a/search/frontendsearchpipeline.py b/search/frontendsearchpipeline.py
index ec0a28e..b606672 100644
--- a/search/frontendsearchpipeline.py
+++ b/search/frontendsearchpipeline.py
@@ -1,7 +1,6 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# Copyright 2016 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
 
 """The FrontendSearchPipeline class manages issue search and sorting.
 
@@ -24,6 +23,7 @@
 import logging
 import math
 import random
+import six
 import time
 
 from google.appengine.api import apiproxy_stub_map
@@ -524,9 +524,9 @@
         cnxn, query_ast, project_ids, services, harmonized_config,
         is_member=member_of_all_projects)
   except query2ast.InvalidQueryError as e:
-    return e.message
+    return str(e)
   except ast2ast.MalformedQuery as e:
-    return e.message
+    return str(e)
 
   return None
 
@@ -551,7 +551,7 @@
     error_responses, services, me_user_ids, logged_in_user_id, new_url_num,
     subqueries, can, group_by_spec, sort_spec, warnings, use_cached_searches):
   # type: (MonorailConnection, Sequence[str], Sequence[int],
-  #     proto.tracker_pb2.ProjectIssueConfig,
+  #     mrproto.tracker_pb2.ProjectIssueConfig,
   #     Mapping[Tuple(int, str), Sequence[int]],
   #     Mapping[Tuple(int, str), Sequence[bool]],
   #     Mapping[Tuple(int, str), Collection[int]], Sequence[Tuple(int, str)],
@@ -690,7 +690,7 @@
 
   Instead, we do the same check, without blocking on any individual RPC.
   """
-  if settings.local_mode:
+  if six.PY3 or settings.local_mode:
     # The development server has very different code for RPCs than the
     # code used in the hosted environment.
     return apiproxy_stub_map.UserRPC.wait_any(active_rpcs)
@@ -777,7 +777,6 @@
       nonviewable_iids[sid] = set(issue_ids)
 
   if sid not in nonviewable_iids:
-    logging.info('nonviewable for %r not found', key)
     logging.info('starting backend call for nonviewable iids %r', key)
     rpc = _StartBackendNonviewableCall(
       pid, logged_in_user_id, sid, invalidation_timestep)
@@ -1048,7 +1047,7 @@
     logging.info('got json text: %r length %r',
                  json_content[:framework_constants.LOGGING_MAX_LENGTH],
                  len(json_content))
-    if json_content == '':
+    if json_content == b'':
       raise Exception('Fast fail')
     json_data = json.loads(json_content)
     unfiltered_iids[shard_key] = json_data['unfiltered_iids']
@@ -1110,7 +1109,7 @@
     logging.info('got json text: %r length %r',
                  json_content[:framework_constants.LOGGING_MAX_LENGTH],
                  len(json_content))
-    if json_content == '':
+    if json_content == b'':
       raise Exception('Fast fail')
     json_data = json.loads(json_content)
     nonviewable_iids[shard_id] = set(json_data['nonviewable'])
@@ -1120,7 +1119,7 @@
       logging.exception(e)
 
     if not remaining_retries:
-      logging.warn('Used all retries, so give up on shard %r', shard_id)
+      logging.warning('Used all retries, so give up on shard %r', shard_id)
       return
 
     if duration_sec >= settings.backend_deadline: