Remove unnecessary exception handling

If we've got a unicode string that needs to be a byte string, encode()ing
as UTF-8 will *always* succeed.

Change-Id: I86e5a76923343149984fe9d962ce41e69e570fc1
This commit is contained in:
Tim Burke 2017-07-17 09:53:39 -07:00
parent ad3f1667ce
commit 0f82ea1871

View File

@ -26,7 +26,6 @@ BufferedHTTPResponse.
make all calls through httplib.
"""
from swift import gettext_ as _
from swift.common import constraints
import logging
import time
@ -203,15 +202,9 @@ def http_connect(ipaddr, port, device, partition, method, path,
:returns: HTTPConnection object
"""
if isinstance(path, six.text_type):
try:
path = path.encode("utf-8")
except UnicodeError as e:
logging.exception(_('Error encoding to UTF-8: %s'), str(e))
path = path.encode("utf-8")
if isinstance(device, six.text_type):
try:
device = device.encode("utf-8")
except UnicodeError as e:
logging.exception(_('Error encoding to UTF-8: %s'), str(e))
device = device.encode("utf-8")
path = quote('/' + device + '/' + str(partition) + path)
return http_connect_raw(
ipaddr, port, method, path, headers, query_string, ssl)