Skip to content
This repository was archived by the owner on Jan 18, 2025. It is now read-only.

Commit 3584b07

Browse files
committed
Always use bytes instead of six.binary_type
`bytes` was introduced in Python 2.6 as an alias for `str`. `six.binary_type` is equivalent to it, but it makes sense to use the native type instead of a compatibilty libray type when there's no difference in them. `bytes` was already being used in most places, this commit replaces the three remaining uses.
1 parent ed36586 commit 3584b07

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

oauth2client/service_account.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import base64
2121
import json
22-
import six
2322
import time
2423

2524
from pyasn1.codec.ber import decoder
@@ -130,7 +129,7 @@ def _urlsafe_b64encode(data):
130129
def _get_private_key(private_key_pkcs8_text):
131130
"""Get an RSA private key object from a pkcs8 representation."""
132131

133-
if not isinstance(private_key_pkcs8_text, six.binary_type):
132+
if not isinstance(private_key_pkcs8_text, bytes):
134133
private_key_pkcs8_text = private_key_pkcs8_text.encode('ascii')
135134
der = rsa.pem.load_pem(private_key_pkcs8_text, 'PRIVATE KEY')
136135
asn1_private_key, _ = decoder.decode(der, asn1Spec=PrivateKeyInfo())

tests/test_oauth2client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,8 @@ def test_no_unicode_in_request_params(self):
644644
http = credentials.authorize(http)
645645
http.request(u'http://example.com', method=u'GET', headers={u'foo': u'bar'})
646646
for k, v in six.iteritems(http.headers):
647-
self.assertEqual(six.binary_type, type(k))
648-
self.assertEqual(six.binary_type, type(v))
647+
self.assertEqual(bytes, type(k))
648+
self.assertEqual(bytes, type(v))
649649

650650
# Test again with unicode strings that can't simply be converted to ASCII.
651651
try:

0 commit comments

Comments
 (0)