Audit all strings in djblets and convert to __future__.unicode_literals

Review Request #4944 — Created Nov. 12, 2013 and submitted

Information

Djblets
master

Reviewers

Audit all strings in djblets and convert to __future__.unicode_literals

This change represents an audit of all of the strings in the djblets codebase.
Where the strings were actually binary data (specifically with our treatment of
settings.EMAIL_HOST_USER and settings.EMAIL_HOST_PASSWORD, and anything passed
into sha1() or md5()), I've made it use the bytes type. Otherwise, these are
now unicode objects by virtue of importing unicode_literals from __future__.

There's also a bunch of fixes to our handling of cache keys, especially those
for large data, much more consistent. We always keep the cache key as a unicode
object and create derivative keys (like the chunk keys for large data) with
that. At the last moment, before calling cache.get() or cache.set(), we pass
that to make_cache_key, which will shorten it if necessary using md5, and then
encode to utf-8 (since not all cache backends support the unicode object as
keys).

  • Verified my assumptions about treatment of unicode vs. str in getattr,
    hasattr, delattr, __getattr__, __hasattr__, __delattr__, hash, regular
    expressions, and memcache keys.
  • Ran djblets unit tests
  • Ran Review Board unit tests
Description From Last Updated

Wrong side of the '

chipx86chipx86

Does the first string need a 'u'?

chipx86chipx86

Does this need a u'?

chipx86chipx86

Should probably be r''

chipx86chipx86

Shouldn't be necessary to put quotes around this. %r should take care of that.

chipx86chipx86
david
chipx86
  1. 
      
  2. djblets/__init__.py (Diff revision 1)
     
     
    Show all issues

    Wrong side of the '

  3. djblets/datagrid/tests.py (Diff revision 1)
     
     
    Show all issues

    Does the first string need a 'u'?

  4. djblets/extensions/errors.py (Diff revision 1)
     
     
    Show all issues

    Does this need a u'?

  5. djblets/extensions/resources.py (Diff revision 1)
     
     
    Show all issues

    Should probably be r''

  6. 
      
david
david
chipx86
  1. Looks fine. Just one thing.

  2. djblets/util/fields.py (Diff revision 4)
     
     
    Show all issues

    Shouldn't be necessary to put quotes around this. %r should take care of that.

  3. 
      
david
Review request changed
Status:
Completed
Change Summary:
Pushed to master (52da427).