Skip to content

Commit

Permalink
Merge pull request #12 from AdRoll/py39-compat
Browse files Browse the repository at this point in the history
Python 3.9 Compatibility
  • Loading branch information
Bill Medernach authored Oct 9, 2020
2 parents bbe85d9 + f12afc9 commit d87f56c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion s3keyring/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package = 's3keyring'
project = "S3 backend for the keyring module"
project_no_spaces = project.replace(' ', '')
version = '0.7.1.post1'
version = '0.8.0.post1'
description = 'Keeps your secrets safe in S3'
authors = ['German Gomez-Herrero']
authors_string = ', '.join(authors)
Expand Down
9 changes: 7 additions & 2 deletions s3keyring/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
from s3keyring.config import Config
from s3keyring.exceptions import ProfileNotFoundError

try:
from base64 import encodestring as b64encode, decodestring as b64decode
except ImportError:
from base64 import encodebytes as b64encode, decodebytes as b64decode

LEGAL_CHARS = (
getattr(string, 'letters', None) # Python 2.x
or getattr(string, 'ascii_letters') # Python 3.x
Expand Down Expand Up @@ -231,7 +236,7 @@ def get_password(self, service, username):
prefix=prefix, bucket=self.bucket.name)
raise PasswordGetError(msg)
pwd_base64 = values[0].get()['Body'].read()
pwd = base64.decodestring(pwd_base64)
pwd = b64decode(pwd_base64)
return pwd.decode('utf-8')

def set_value(self, *args, **kwargs):
Expand All @@ -244,7 +249,7 @@ def set_password(self, service, username, password):
service = _escape_for_s3(service)
username = _escape_for_s3(username)

pwd_base64 = base64.encodestring(password.encode('utf-8')).decode()
pwd_base64 = b64encode(password.encode('utf-8')).decode()

# Save in S3 using both server and client side encryption
keyname = self._get_s3_key(service, username)
Expand Down

0 comments on commit d87f56c

Please sign in to comment.