Merge branch 'main' into avm99963-monorail

Merged commit 34d8229ae2b51fb1a15bd208e6fe6185c94f6266

GitOrigin-RevId: 7ee0917f93a577e475f8e09526dd144d245593f4
diff --git a/framework/gcs_helpers.py b/framework/gcs_helpers.py
index 9da5b11..fd282e0 100644
--- a/framework/gcs_helpers.py
+++ b/framework/gcs_helpers.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.
 
 """Set of helpers for interacting with Google Cloud Storage."""
 from __future__ import print_function
@@ -10,6 +9,7 @@
 
 import logging
 import os
+import six
 from six.moves import urllib
 import uuid
 
@@ -96,7 +96,7 @@
       # Don't log the whole exception because we don't need to see
       # this on the Cloud Error Reporting page.
       logging.info('Got LargeImageError on image with %d bytes', len(content))
-    except Exception, e:
+    except Exception as e:
       # Do not raise exception for incorrectly formed images.
       # See https://bugs.chromium.org/p/monorail/issues/detail?id=597 for more
       # detail.
@@ -132,7 +132,7 @@
   """Request that devstorage API signs a GCS content URL."""
   resp = urlfetch.fetch(url, follow_redirects=False)
   redir = resp.headers["Location"]
-  return redir
+  return six.ensure_str(redir)
 
 
 def SignUrl(bucket, object_id):
@@ -149,7 +149,7 @@
     cache_key = 'gcs-object-url-%s' % object_id
     cached = memcache.get(key=cache_key)
     if cached is not None:
-      return cached
+      return six.ensure_str(cached)
 
     if IS_DEV_APPSERVER:
       attachment_url = '/_ah/gcs/%s%s' % (bucket, object_id)