[PATCH 5/7] py3k: the basestring and unicode types are removed in python 3

2012-01-08 Thread Justus Winter
Hi Tomi, Hi Sebastian :)

Quoting Tomi Ollila (2012-01-04 19:07:11)
>On Mon, 02 Jan 2012 16:15:58 +0100, Sebastian Spaeth  
>wrote:
>> Happy new year. Pushed patches 1-4 of this series so far. Looking fine,

nice, thanks.

>> but ugh, the below seems like a rather ugly hack in a function that is
>> probably called quite often.
>>
>> Isn't there a more pretty variant avoiding these sys.version_info checks
>> all over the place?

Well, I rebased and updated this patch. There are now two different
implementations of _str like there are two Python3StringMixIn
classes. I'll send this patch as reply to this message.

>Does the Python3StringMixIn stuff in later patches already handle this
>patch -- and making this obsolete ?

No, that only handles the __str__ and __unicode__ stuff.

Cheers,
Justus


Re: [PATCH 5/7] py3k: the basestring and unicode types are removed in python 3

2012-01-08 Thread Justus Winter
Hi Tomi, Hi Sebastian :)

Quoting Tomi Ollila (2012-01-04 19:07:11)
>On Mon, 02 Jan 2012 16:15:58 +0100, Sebastian Spaeth  
>wrote:
>> Happy new year. Pushed patches 1-4 of this series so far. Looking fine,

nice, thanks.

>> but ugh, the below seems like a rather ugly hack in a function that is
>> probably called quite often.
>>
>> Isn't there a more pretty variant avoiding these sys.version_info checks
>> all over the place?

Well, I rebased and updated this patch. There are now two different
implementations of _str like there are two Python3StringMixIn
classes. I'll send this patch as reply to this message.

>Does the Python3StringMixIn stuff in later patches already handle this
>patch -- and making this obsolete ?

No, that only handles the __str__ and __unicode__ stuff.

Cheers,
Justus
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 5/7] py3k: the basestring and unicode types are removed in python 3

2012-01-05 Thread Tomi Ollila
On Mon, 02 Jan 2012 16:15:58 +0100, Sebastian Spaeth  
wrote:
> Happy new year. Pushed patches 1-4 of this series so far. Looking fine,
> but ugh, the below seems like a rather ugly hack in a function that is
> probably called quite often.
> 
> Isn't there a more pretty variant avoiding these sys.version_info checks
> all over the place?
> 
> > @@ -200,9 +201,9 @@ def _str(value):
> >  
> >  C++ code expects strings to be well formatted and
> >  unicode strings to have no null bytes."""
> > -if not isinstance(value, basestring):
> > +if not isinstance(value, basestring if sys.version_info[0] == 2 else 
> > str):
> >  raise TypeError("Expected str or unicode, got %s" % 
> > str(type(value)))
> > -if isinstance(value, unicode):
> > +if sys.version_info[0] == 3 or isinstance(value, unicode):
> >  return value.encode('UTF-8')
> >  return value

Does the Python3StringMixIn stuff in later patches already handle this
patch -- and making this obsolete ?

Tomi
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 5/7] py3k: the basestring and unicode types are removed in python 3

2012-01-04 Thread Tomi Ollila
On Mon, 02 Jan 2012 16:15:58 +0100, Sebastian Spaeth  
wrote:
> Happy new year. Pushed patches 1-4 of this series so far. Looking fine,
> but ugh, the below seems like a rather ugly hack in a function that is
> probably called quite often.
> 
> Isn't there a more pretty variant avoiding these sys.version_info checks
> all over the place?
> 
> > @@ -200,9 +201,9 @@ def _str(value):
> >  
> >  C++ code expects strings to be well formatted and
> >  unicode strings to have no null bytes."""
> > -if not isinstance(value, basestring):
> > +if not isinstance(value, basestring if sys.version_info[0] == 2 else 
> > str):
> >  raise TypeError("Expected str or unicode, got %s" % 
> > str(type(value)))
> > -if isinstance(value, unicode):
> > +if sys.version_info[0] == 3 or isinstance(value, unicode):
> >  return value.encode('UTF-8')
> >  return value

Does the Python3StringMixIn stuff in later patches already handle this
patch -- and making this obsolete ?

Tomi


Re: [PATCH 5/7] py3k: the basestring and unicode types are removed in python 3

2012-01-03 Thread Sebastian Spaeth
Happy new year. Pushed patches 1-4 of this series so far. Looking fine,
but ugh, the below seems like a rather ugly hack in a function that is
probably called quite often.

Isn't there a more pretty variant avoiding these sys.version_info checks
all over the place?

> @@ -200,9 +201,9 @@ def _str(value):
>  
>  C++ code expects strings to be well formatted and
>  unicode strings to have no null bytes."""
> -if not isinstance(value, basestring):
> +if not isinstance(value, basestring if sys.version_info[0] == 2 else 
> str):
>  raise TypeError("Expected str or unicode, got %s" % str(type(value)))
> -if isinstance(value, unicode):
> +if sys.version_info[0] == 3 or isinstance(value, unicode):
>  return value.encode('UTF-8')
>  return value


pgpsZskLRluHs.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 5/7] py3k: the basestring and unicode types are removed in python 3

2012-01-02 Thread Sebastian Spaeth
Happy new year. Pushed patches 1-4 of this series so far. Looking fine,
but ugh, the below seems like a rather ugly hack in a function that is
probably called quite often.

Isn't there a more pretty variant avoiding these sys.version_info checks
all over the place?

> @@ -200,9 +201,9 @@ def _str(value):
>  
>  C++ code expects strings to be well formatted and
>  unicode strings to have no null bytes."""
> -if not isinstance(value, basestring):
> +if not isinstance(value, basestring if sys.version_info[0] == 2 else 
> str):
>  raise TypeError("Expected str or unicode, got %s" % str(type(value)))
> -if isinstance(value, unicode):
> +if sys.version_info[0] == 3 or isinstance(value, unicode):
>  return value.encode('UTF-8')
>  return value
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 



[PATCH 5/7] py3k: the basestring and unicode types are removed in python 3

2011-12-14 Thread Justus Winter
---
 bindings/python/notmuch/globals.py |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/bindings/python/notmuch/globals.py 
b/bindings/python/notmuch/globals.py
index 99e6a10..c52790c 100644
--- a/bindings/python/notmuch/globals.py
+++ b/bindings/python/notmuch/globals.py
@@ -17,6 +17,7 @@ along with notmuch.  If not, see 
.
 Copyright 2010 Sebastian Spaeth '
 """

+import sys
 from ctypes import CDLL, c_char_p, c_int, Structure, POINTER

 #-
@@ -200,9 +201,9 @@ def _str(value):

 C++ code expects strings to be well formatted and
 unicode strings to have no null bytes."""
-if not isinstance(value, basestring):
+if not isinstance(value, basestring if sys.version_info[0] == 2 else str):
 raise TypeError("Expected str or unicode, got %s" % str(type(value)))
-if isinstance(value, unicode):
+if sys.version_info[0] == 3 or isinstance(value, unicode):
 return value.encode('UTF-8')
 return value

-- 
1.7.7.3



[PATCH 5/7] py3k: the basestring and unicode types are removed in python 3

2011-12-14 Thread Justus Winter
---
 bindings/python/notmuch/globals.py |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/bindings/python/notmuch/globals.py 
b/bindings/python/notmuch/globals.py
index 99e6a10..c52790c 100644
--- a/bindings/python/notmuch/globals.py
+++ b/bindings/python/notmuch/globals.py
@@ -17,6 +17,7 @@ along with notmuch.  If not, see 
.
 Copyright 2010 Sebastian Spaeth '
 """
 
+import sys
 from ctypes import CDLL, c_char_p, c_int, Structure, POINTER
 
 #-
@@ -200,9 +201,9 @@ def _str(value):
 
 C++ code expects strings to be well formatted and
 unicode strings to have no null bytes."""
-if not isinstance(value, basestring):
+if not isinstance(value, basestring if sys.version_info[0] == 2 else str):
 raise TypeError("Expected str or unicode, got %s" % str(type(value)))
-if isinstance(value, unicode):
+if sys.version_info[0] == 3 or isinstance(value, unicode):
 return value.encode('UTF-8')
 return value
 
-- 
1.7.7.3

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch