Merge lp://staging/~brian.curtin/ubuntu-sso-client/py3-unicode into lp://staging/ubuntu-sso-client

Proposed by Brian Curtin
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 998
Merged at revision: 987
Proposed branch: lp://staging/~brian.curtin/ubuntu-sso-client/py3-unicode
Merge into: lp://staging/ubuntu-sso-client
Diff against target: 470 lines (+118/-53)
9 files modified
ubuntu_sso/account.py (+12/-10)
ubuntu_sso/credentials.py (+3/-3)
ubuntu_sso/keyring/__init__.py (+13/-8)
ubuntu_sso/keyring/tests/test_common.py (+11/-9)
ubuntu_sso/keyring/tests/test_linux.py (+3/-1)
ubuntu_sso/main/__init__.py (+2/-1)
ubuntu_sso/main/tests/test_common.py (+5/-3)
ubuntu_sso/tests/test_account.py (+20/-18)
ubuntu_sso/utils/compat.py (+49/-0)
To merge this branch: bzr merge lp://staging/~brian.curtin/ubuntu-sso-client/py3-unicode
Reviewer Review Type Date Requested Status
Mike McCracken (community) Approve
Alejandro J. Cura (community) Approve
Review via email: mp+112856@code.staging.launchpad.net

Commit message

The first of several changes to prepare sso for Python 3 Unicode usage

Description of the change

The first of several branches which prepare our code to work with both Python 2 and 3 with respect to Unicode. Since we support Python 2.6 and beyond as well as Python 3, we make use of the "from __future__ import unicode_literals" compile change, which makes things a lot easier.

In addition, I introduced ubuntu_sso.utils.compat (at the very end of the diff) which is the start of the minimal compatibility layer we'll need to maintain between Python 2 and 3. It's a fairly common approach, and as stated in the accompanying comment, it's outlined at http://python3porting.com/noconv.html#more-bytes-strings-and-unicode

(compat may make sense to move into something like devtools at a later time. I figure it's best to keep small changes self-contained for the time being before we do any cross-project changes)

This change covers modules in the following packages:
ubuntu_sso
ubuntu_sso.gtk
ubuntu_sso.keyring
ubuntu_sso.main

To post a comment you must log in.
Revision history for this message
Alejandro J. Cura (alecu) wrote :

This series of py3k branches is looking awesome, thanks for working on it!

One thing we should consider: in every file where we add the "from __future__ import unicode_literals" we should be extra careful about the string literals that we are not turning from u"..." to "...".

I can see two different cases happening here:
 * In some places the old code assumes that conversions when comparing unicode with str are automatic, so to make this work on 3 we should leave old string literal as they are.
 * In some other places some old string literals should be changed from "..." to "...".encode(...), because they are truly using "byte literals". For instance in many of the tests in ubuntu_sso/keyring/tests/test_common.py that fake some functions that will still return bytes on py3.

review: Needs Fixing
Revision history for this message
Brian Curtin (brian.curtin) wrote :

I think the above changes should have this addressed. Rather than changing the tests, I made the implementation more Python 3 safe. keyring.gethostname actually would not work on 3 anyway.

Revision history for this message
Alejandro J. Cura (alecu) wrote :

== Python Lint Notices ==

ubuntu_sso/qt/__init__.py:
    50: [W0511] TODO

ubuntu_sso/utils/compat.py:
    42: [W0622] Redefining built-in 'basestring'
    40: [C0103] Invalid name "text_type" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)
    41: [C0103] Invalid name "binary_type" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)
    42: [C0103] Invalid name "basestring" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)
    44: [C0103] Invalid name "text_type" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)
    45: [C0103] Invalid name "binary_type" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)
    46: [C0103] Invalid name "basestring" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)

ubuntu_sso/utils/webclient/common.py:
    286: [W0511] TODO

Revision history for this message
Alejandro J. Cura (alecu) :
review: Needs Fixing
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Other than lint issues, I've run the tests on Ubuntu, and ran the sso client irl, and it seems to be working fine.

998. By Brian Curtin

Disable lint warnings for basestring redefine, invalid names

Revision history for this message
Alejandro J. Cura (alecu) wrote :

Looks good!

review: Approve
Revision history for this message
Mike McCracken (mikemc) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches