From e84d531b954a906caa68cc962c64404dd8c958d3 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Tue, 21 Apr 2020 11:43:52 -0700 Subject: [PATCH] py3: Make etag-quoter work Previously, func tests (might?) complain like TypeError: 'dict_items' object does not support item assignment Change-Id: Ic1a81f5b7262942ea52aa1de87cfcde25a2457ba --- swift/common/middleware/etag_quoter.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/swift/common/middleware/etag_quoter.py b/swift/common/middleware/etag_quoter.py index 8cc527579b..ea3cbb30d6 100644 --- a/swift/common/middleware/etag_quoter.py +++ b/swift/common/middleware/etag_quoter.py @@ -105,11 +105,11 @@ class EtagQuoterMiddleware(object): status, headers, resp_iter = req.call_application(self.app) - for i, (header, value) in enumerate(headers): - if header.lower() == 'etag': - if not value.startswith(('"', 'W/"')) or \ - not value.endswith('"'): - headers[i] = (header, '"%s"' % value) + headers = [ + (header, value) if header.lower() != 'etag' or ( + value.startswith(('"', 'W/"')) and value.endswith('"')) + else (header, '"%s"' % value) + for header, value in headers] start_response(status, headers) return resp_iter