[Python-Dev] unicode: strange exception

M.-A. Lemburg mal@lemburg.com
Mon, 03 Apr 2000 23:45:20 +0200


Fredrik Lundh wrote:
> 
> >>> "!" in ("a", None)
> 0
> >>> u"!" in ("a", None)
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
> TypeError: expected a character buffer object

Good catch. The same happens when you try to compare
Unicode and a different non-string type:

>>> '1' == None
0
>>> u'1' == None
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: expected a character buffer object

The reason is the same in both cases: failing auto-coercion.
I will send a patch for this tomorrow.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/