george young wrote:

[pygtk-1.99.15, gtk+-2.2.1, python 2.3.a1, x86 linux]
I have used ls = ListStore(str, str, str)


with success, but
 ls = ListStore(bool, str, str)

fails with a nasty, misleading "could not get typecode from object" in a
*subsequent* statement! If I change "bool" to gobject.TYPE_BOOLEAN, it
works fine. Eeek, this took me a long while to debug! Are python type
objects like "str" and "bool" not supposed to be used here? And why doesn't
the traceback point to the appropriate offending statement?


The problem with exception occuring in the subsequent function call has been fixed in more recent versions of pygtk (the constructor was returning NULL after raising the exception, when it should have been returning -1).

As for using Python types to represent column types, the function that converts Python objects to GTypes does not handle "bool" (mostly because Python 2.2.x is the base requirement, and doesn't have a native boolean type).

Making pygtk interpret bool as boolean sounds like a good idea though. The two options for implementing this are:

  1. conditionally interpret &PyBoolean_Type as G_TYPE_BOOLEAN if pygtk
     was compiled with Python 2.3.
  2. look up "bool" in __builtins__, and treat that object as eqivalent
     to G_TYPE_BOOLEAN (bool will be a function on 2.2, and a type on
      >= 2.3).

James.

--
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to