mirror of
https://github.com/certbot/certbot.git
synced 2026-06-03 22:08:07 -04:00
b64encode: no support for bytearray (py2.6 problems)
This commit is contained in:
parent
596132292a
commit
5859e87ced
2 changed files with 3 additions and 7 deletions
|
|
@ -22,7 +22,7 @@ def b64encode(data):
|
|||
"""JOSE Base64 encode.
|
||||
|
||||
:param data: Data to be encoded.
|
||||
:type data: `bytes` or `bytearray`
|
||||
:type data: `bytes`
|
||||
|
||||
:returns: JOSE Base64 string.
|
||||
:rtype: bytes
|
||||
|
|
@ -30,9 +30,8 @@ def b64encode(data):
|
|||
:raises TypeError: if `data` is of incorrect type
|
||||
|
||||
"""
|
||||
if not isinstance(data, (six.binary_type, bytearray)):
|
||||
raise TypeError('argument should be {0} or bytearray'.format(
|
||||
six.binary_type))
|
||||
if not isinstance(data, six.binary_type):
|
||||
raise TypeError('argument should be {0}'.format(six.binary_type))
|
||||
return base64.urlsafe_b64encode(data).rstrip(b'=')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -39,9 +39,6 @@ class B64EncodeTest(unittest.TestCase):
|
|||
for text, (b64, _) in six.iteritems(B64_PADDING_EXAMPLES):
|
||||
self.assertEqual(self._call(text), b64)
|
||||
|
||||
def test_bytearray_ok(self):
|
||||
self.assertEqual(self._call(bytearray(b'foo')), b'Zm9v')
|
||||
|
||||
def test_unicode_fails_with_type_error(self):
|
||||
self.assertRaises(TypeError, self._call, u'some unicode')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue