[Bug 1685547] Re: Crash in python3 with the 'file' backend

Dmitry Shachnev mitya57 at gmail.com
Wed Apr 26 15:29:20 UTC 2017


Nevermind. I have asked the upstream developer of python-keyring, and he
says that only unicode passwords are supported [1]. Here launchpadlib is
trying to save a bytes password, which is a bug. So I am reassigning
this to python3-launchpadlib.

Looking at launchpadlib source, the password is automatically generated
and then encoded with base64. I am not sure if base64 is still needed
(any unicode characters should work; if no, please report a bug and
specify the backend used). But in any case, you can easily convert bytes
to unicode by using .decode('latin-1') (and then .encode('latin-1') back
when reading the password from the keyring).

[1]: https://github.com/jaraco/keyring/issues/275

** Bug watch added: github.com/jaraco/keyring/issues #275
   https://github.com/jaraco/keyring/issues/275

** Package changed: python-keyring (Ubuntu) => python-launchpadlib
(Ubuntu)

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to python-keyring in Ubuntu.
https://bugs.launchpad.net/bugs/1685547

Title:
  Crash in python3 with the 'file' backend

Status in Kubuntu Automation:
  New
Status in python-launchpadlib package in Ubuntu:
  New

Bug description:
  Hi,

  I have a program written in python 3 which uses launchpadlib, and it's
  crashing if it tries to use the 'file' backend:

  $ kubuntu-retry-builds -r frameworks -d artful
  Logs are activated and are going to be stored in:
  /home/santa/kubuntu-retry-builds_logs
  If you want to disable this feature, edit your ~/kubuntu-automation.conf
  Date started: Sat, 22 Apr 2017 22:52:10 +0200
  The authorization page:
   (https://launchpad.net/+authorize-token?oauth_token=qp1rQXkMXWMMj0pQBHgq&allow_permission=DESKTOP_INTEGRATION)
  should be opening in your browser. Use your browser to authorize
  this program to access Launchpad on your behalf.
  Waiting to hear from Launchpad about your decision...
  Traceback (most recent call last):
    File "/usr/bin/kubuntu-retry-builds", line 90, in <module>
      lp = Launchpad.login_with("kubuntu-retry-builds", "production")
    File "/usr/lib/python3/dist-packages/launchpadlib/launchpad.py", line 549, in login_with
      credential_save_failed, version)
    File "/usr/lib/python3/dist-packages/launchpadlib/launchpad.py", line 356, in _authorize_token_and_login
      credentials = authorization_engine(credentials, credential_store)
    File "/usr/lib/python3/dist-packages/launchpadlib/credentials.py", line 553, in __call__
      credential_store.save(credentials, self.unique_consumer_id)
    File "/usr/lib/python3/dist-packages/launchpadlib/credentials.py", line 308, in save
      raise e
    File "/usr/lib/python3/dist-packages/launchpadlib/credentials.py", line 303, in save
      self.do_save(credentials, unique_consumer_id)
    File "/usr/lib/python3/dist-packages/launchpadlib/credentials.py", line 385, in do_save
      'launchpadlib', unique_key, serialized)
    File "/usr/lib/python3/dist-packages/keyring/core.py", line 48, in set_password
      _keyring_backend.set_password(service_name, username, password)
    File "/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' 

  As a workaround I replaced the file.py line in question with:
  password_encrypted = self.encrypt(str(password).encode('utf-8'))
  and now it works.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ka/+bug/1685547/+subscriptions



More information about the foundations-bugs mailing list