[PATCH 3/7] py3k: All strings are unicode strings in py3k

Justus Winter 4winter at informatik.uni-hamburg.de
Wed Dec 14 04:52:01 PST 2011


Hi Tomi :)

Quoting Tomi Ollila (2011-12-14 13:17:41)
>On Wed, 14 Dec 2011 11:58:21 +0100, Justus Winter <4winter at informatik.uni-hamburg.de> wrote:
>> ---
>>  bindings/python/notmuch/globals.py |    4 ++--
>>  1 files changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py
>> index 54a49b2..99e6a10 100644
>> --- a/bindings/python/notmuch/globals.py
>> +++ b/bindings/python/notmuch/globals.py
>> @@ -51,7 +51,7 @@ class Status(Enum):
>>          """Get a (unicode) string representation of a notmuch_status_t value."""
>>          # define strings for custom error messages
>>          if status == STATUS.NOT_INITIALIZED:
>> -            return u"Operation on uninitialized object impossible."
>> +            return "Operation on uninitialized object impossible."
>>          return unicode(Status._status2str(status))
>>  
>>  STATUS = Status(['SUCCESS',
>> @@ -142,7 +142,7 @@ class NotmuchError(Exception):
>>          elif self.status is not None:
>>              return STATUS.status2str(self.status)
>>          else:
>> -            return u'Unknown error'
>> +            return 'Unknown error'
>
>Is this u -prefix unnecessary in python 2 too ? Grepping
>'u"' and "u'" in **/*.py in puthon bindings source resulted
>some more u-prefixed strings in docs/source/conf.py. Should
>these be changed in some future patch ?

Well, since the string literal contains no non-ascii characters it is
perfectly safe to just use a (python2.x) string literal and it will be
automatically coerced to unicode if it is used in a unicode context.

OTOH it is possible to use

from __future__ import unicode_literals

to turn all string literals to unicode literals in python 2.x.

Justus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .signature
Type: application/octet-stream
Size: 17 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20111214/30164683/attachment-0001.obj>


More information about the notmuch mailing list