Skip to content
This repository was archived by the owner on May 9, 2020. It is now read-only.

Commit 1fa2db2

Browse files
author
Roma Koshel
committed
Remove optional 'utf-8' argument from encode/decode
1 parent f03f341 commit 1fa2db2

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

chef/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def __exit__(self, type, value, traceback):
202202
def _request(self, method, url, data, headers):
203203
# Testing hook, subclass and override for WSGI intercept
204204
if six.PY3 and data:
205-
data = data.encode('utf-8')
205+
data = data.encode()
206206
request = ChefRequest(url, data, headers, method=method)
207207
return six.moves.urllib.request.urlopen(request).read()
208208

@@ -222,7 +222,7 @@ def request(self, method, path, headers={}, data=None):
222222
except six.moves.urllib.error.HTTPError as e:
223223
e.content = e.read()
224224
try:
225-
e.content = json.loads(e.content.decode("utf-8"))
225+
e.content = json.loads(e.content.decode())
226226
raise ChefServerError.from_error(e.content['error'], code=e.code)
227227
except ValueError:
228228
pass
@@ -236,7 +236,7 @@ def api_request(self, method, path, headers={}, data=None):
236236
headers['content-type'] = 'application/json'
237237
data = json.dumps(data)
238238
response = self.request(method, path, headers, data)
239-
return json.loads(response.decode('utf-8'))
239+
return json.loads(response.decode())
240240

241241
def __getitem__(self, path):
242242
return self.api_request('GET', path)

chef/rsa.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def __init__(self, fp=None):
152152
self.public = False
153153
if not fp:
154154
return
155-
if isinstance(fp, six.binary_type) and fp.startswith('-----'.encode('utf-8')):
155+
if isinstance(fp, six.binary_type) and fp.startswith('-----'.encode()):
156156
# PEM formatted text
157157
self.raw = fp
158158
elif isinstance(fp, six.string_types):
@@ -190,7 +190,7 @@ def private_encrypt(self, value, padding=RSA_PKCS1_PADDING):
190190
if self.public:
191191
raise SSLError('private method cannot be used on a public key')
192192
if six.PY3 and not isinstance(value, bytes):
193-
buf = create_string_buffer(bytes(value, encoding='utf-8'), len(value))
193+
buf = create_string_buffer(value.encode(), len(value))
194194
else:
195195
buf = create_string_buffer(value, len(value))
196196
size = RSA_size(self.key)
@@ -202,7 +202,7 @@ def private_encrypt(self, value, padding=RSA_PKCS1_PADDING):
202202

203203
def public_decrypt(self, value, padding=RSA_PKCS1_PADDING):
204204
if six.PY3 and not isinstance(value, bytes):
205-
buf = create_string_buffer(bytes(value, encoding='utf-8'), len(value))
205+
buf = create_string_buffer(value.encode(), len(value))
206206
else:
207207
buf = create_string_buffer(value, len(value))
208208
size = RSA_size(self.key)
@@ -211,7 +211,7 @@ def public_decrypt(self, value, padding=RSA_PKCS1_PADDING):
211211
if ret <= 0:
212212
raise SSLError('Unable to decrypt data')
213213
if six.PY3 and isinstance(output.raw, bytes):
214-
return str(output.raw[:ret], encoding='utf-8')
214+
return output.raw[:ret].decode()
215215
else:
216216
return output.raw[:ret]
217217

0 commit comments

Comments
 (0)