unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: Justus Winter <4winter@informatik.uni-hamburg.de>,
	notmuch@notmuchmail.org
Subject: Re: [PATCH 6/7] py3k: Add and use a mixin class that implements __str__
Date: Wed, 14 Dec 2011 14:26:38 +0200	[thread overview]
Message-ID: <yf6obvbs5j5.fsf@taco2.nixu.fi> (raw)
In-Reply-To: <1323860305-15802-7-git-send-email-4winter@informatik.uni-hamburg.de>

On Wed, 14 Dec 2011 11:58:24 +0100, Justus Winter <4winter@informatik.uni-hamburg.de> wrote:
> ---
[ ... snip ... ]

>  
> -class Filenames(object):
> +class Filenames(Python3StringMixIn):
>      """Represents a list of filenames as returned by notmuch
>  
>      This object contains the Filenames iterator. The main function is
> @@ -98,9 +98,6 @@ class Filenames(object):
>  
>          self._files = None
>  
> -    def __str__(self):
> -        return unicode(self).encode('utf-8')
> -
>      def __unicode__(self):
>          """Represent Filenames() as newline-separated list of full paths
>  
> diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py
> index c52790c..2111b86 100644
> --- a/bindings/python/notmuch/globals.py
> +++ b/bindings/python/notmuch/globals.py
> @@ -28,6 +28,16 @@ except:
>      raise ImportError("Could not find shared 'notmuch' library.")
>  
>  
> +if sys.version_info[0] == 2:
> +    class Python3StringMixIn(object):
> +        def __str__(self):
> +            return unicode(self).encode('utf-8')
> +else:
> +    class Python3StringMixIn(object):
> +        def __str__(self):
> +            return self.__unicode__()
> +
> +

[ ... snip ... ]

> -class Threads(object):
> +class Threads(Python3StringMixIn):
>      """Represents a list of notmuch threads
>  
>      This object provides an iterator over a list of notmuch threads
> @@ -393,7 +393,7 @@ class Thread(object):
>          return Tags(tags_p, self)
>  
>      def __str__(self):
> -        return unicode(self).encode('utf-8')
> +        return self.__unicode__().encode('utf-8')
>  
>      def __unicode__(self):
>          frm = "thread:%s %12s [%d/%d] %s; %s (%s)"

Is this class special case ? in all other classes
the __str__() function has been removed (using inherited
function) ?

> -- 
> 1.7.7.3

Otherwise LGTM -- pretty simple and effective (all 7 patches).

Tomi

  reply	other threads:[~2011-12-14 12:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-14 10:58 [python] RFC: supporting python 2 and 3 with one codebase Justus Winter
2011-12-14 10:58 ` [PATCH 1/7] py3k: The execfile built-in has been removed in python 3 Justus Winter
2011-12-14 10:58 ` [PATCH 2/7] py3k: The ConfigParser module has been renamed to configparser Justus Winter
2011-12-14 10:58 ` [PATCH 3/7] py3k: All strings are unicode strings in py3k Justus Winter
2011-12-14 12:17   ` Tomi Ollila
2011-12-14 12:52     ` Justus Winter
2011-12-14 10:58 ` [PATCH 4/7] py3k: Rename .next() to __next__(), add python2.x compatibility alias Justus Winter
2011-12-14 10:58 ` [PATCH 5/7] py3k: the basestring and unicode types are removed in python 3 Justus Winter
2012-01-02 15:15   ` Sebastian Spaeth
2012-01-04 18:07     ` Tomi Ollila
2012-01-08 14:04       ` Justus Winter
2012-01-08 14:06         ` [PATCH] " Justus Winter
2011-12-14 10:58 ` [PATCH 6/7] py3k: Add and use a mixin class that implements __str__ Justus Winter
2011-12-14 12:26   ` Tomi Ollila [this message]
2011-12-14 12:56     ` Justus Winter
2011-12-14 13:04       ` Justus Winter
2011-12-14 10:58 ` [PATCH 7/7] python: add missing conversions from and to utf-8 Justus Winter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yf6obvbs5j5.fsf@taco2.nixu.fi \
    --to=tomi.ollila@iki.fi \
    --cc=4winter@informatik.uni-hamburg.de \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).