no encode method on password as it is bytes in py3

Bug #1709573 reported by Christian Ehrhardt 
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
git-ubuntu
New
Undecided
Unassigned
launchpadlib
New
Undecided
Unassigned

Bug Description

Hi,
I've seen various cases on my system of this error - on Xenial which my system is, but also on snaps that clearly work for others - so there must be a portion of my "system setup" involved that triggers this I don't see yet.

The issue appears as:
[...]
  File "/snap/git-ubuntu/114/usr/lib/python3/dist-packages/launchpadlib/credentials.py", line 384, in do_save
    'launchpadlib', unique_key, serialized)
  File "/snap/git-ubuntu/114/usr/lib/python3/dist-packages/keyring/core.py", line 48, in set_password
    _keyring_backend.set_password(service_name, username, password)
  File "/snap/git-ubuntu/114/usr/lib/python3/dist-packages/keyring/backends/file.py", line 87, in set_password
    password_encrypted = self.encrypt(password.encode('utf-8'))
AttributeError: 'bytes' object has no attribute 'encode

And that essentially is:
/usr/lib/python3/dist-packages/launchpadlib/credentials.py
360 B64MARKER = b"<B64>"
...
382 serialized = self.B64MARKER + b64encode(serialized)
383 keyring.set_password(
384 'launchpadlib', unique_key, serialized)
...
/usr/lib/python3/dist-packages/keyring/backends/file.py
 87 password_encrypted = self.encrypt(password.encode('utf-8'))

Now in python3 b64encode returns bytes and B64MARKER clearly is defined as bytes.
So the object arriving at the encode call is "bytes".
But encode is a method of string not bytes which triggers the error.

I beg your pardon for not (yet) seeing why this hits me but not others.
I almost expect more to be updated on my py-foo than a bug-fix :-/

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.