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:
parent
ad3f1667ce
commit
0f82ea1871
@ -26,7 +26,6 @@ BufferedHTTPResponse.
|
|||||||
make all calls through httplib.
|
make all calls through httplib.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from swift import gettext_ as _
|
|
||||||
from swift.common import constraints
|
from swift.common import constraints
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
@ -203,15 +202,9 @@ def http_connect(ipaddr, port, device, partition, method, path,
|
|||||||
:returns: HTTPConnection object
|
:returns: HTTPConnection object
|
||||||
"""
|
"""
|
||||||
if isinstance(path, six.text_type):
|
if isinstance(path, six.text_type):
|
||||||
try:
|
path = path.encode("utf-8")
|
||||||
path = path.encode("utf-8")
|
|
||||||
except UnicodeError as e:
|
|
||||||
logging.exception(_('Error encoding to UTF-8: %s'), str(e))
|
|
||||||
if isinstance(device, six.text_type):
|
if isinstance(device, six.text_type):
|
||||||
try:
|
device = device.encode("utf-8")
|
||||||
device = device.encode("utf-8")
|
|
||||||
except UnicodeError as e:
|
|
||||||
logging.exception(_('Error encoding to UTF-8: %s'), str(e))
|
|
||||||
path = quote('/' + device + '/' + str(partition) + path)
|
path = quote('/' + device + '/' + str(partition) + path)
|
||||||
return http_connect_raw(
|
return http_connect_raw(
|
||||||
ipaddr, port, method, path, headers, query_string, ssl)
|
ipaddr, port, method, path, headers, query_string, ssl)
|
||||||
|
Loading…
Reference in New Issue
Block a user