unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Unicode in Python bindings
@ 2013-07-07  7:00 Amadeusz Żołnowski
  0 siblings, 0 replies; only message in thread
From: Amadeusz Żołnowski @ 2013-07-07  7:00 UTC (permalink / raw)
  To: Justus Winter

[-- Attachment #1: Type: text/plain, Size: 1280 bytes --]

Hello,

I have come across a problem with Unicode [1] in afew mail filter which
uses Notmuch Python bindings and it has eventually bringed us to
confusion about Unicode handling in Python bindings.

Shouldn't __unicode__() methods return value of type unicode?  Let's
take an example of __unicode__() method from Message class:

    def __unicode__(self):
        format = "%s (%s) (%s)"
        return format % (self.get_header('from'),
                         self.get_tags(),                
                         date.fromtimestamp(self.get_date()),
                        )

format is of type str, not unicode and method is eventually going to
return str, while the user of the API is expecting unicode type.

I haven't programmed in Python 3, yet - only in Python 2, so maybe I am
missing something.  When I was writing a big project in Python 2, I have
eventually decided to use u'' literals everywhere and decode any str to
unicode ASAP - and this solved all issues wrt encodings.  I guess that
mixing Python 2 and 3 gets even more problematic.

Could you review (and fix if it is needed) Python bindings in context of
unicode handling, please?


[1] https://github.com/teythoon/afew/issues/36


Regards,

-- 
Amadeusz Żołnowski

[-- Attachment #2: Type: application/pgp-signature, Size: 489 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-07-09  9:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-07  7:00 Unicode in Python bindings Amadeusz Żołnowski

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).