[wxPython] wxTreeCtrl problems

[NT, wxPython 2.1.15]

I'm guessing this is a SWIG bug (?), but in the 2.1.15 release of wxPython
comparing at least one wxwindows object to None results in a seg fault.
Here's some sample code to demonstrate, taken from the wxTreeCtrl demo:

    def OnRightClick(self, event):
        pt = event.GetPosition();
        #item = self.tree.HitTest(pt)
        #self.log.WriteText("OnRightClick: %s\n" %
self.tree.GetItemText(item))
        #self.tree.SelectItem(item)
        itm = self.tree.GetSelection()
        print 'here we go'
        if itm == None:
            print 'okey dokey'

(I had to comment out some stuff because it no longer works with the new
wxPython... sorry, but I haven't tracked this down yet)

that code will cause a seg fault (on NT at least). replacing the '=='
with 'is' on the second to last line causes everything to run just fine.

I have a coworker who can't seem to remember to use 'is' when testing
for None, so I'm guessing I'll find more instances of this problem.

Boy was that one a pain in the neck to track down.

-greg

···

----
Greg Landrum, Ph.D. glandrum@combichem.com
Sr. Research Scientist Dupont Pharmaceutical Research Lab
Tel: (650)842-0560 x115 Fax: (650)842-0575

[NT, wxPython 2.1.15]

I'm guessing this is a SWIG bug (?), but in the 2.1.15 release of wxPython
comparing at least one wxwindows object to None results in a seg fault.

Thanks, found and fixed. The wxTreeItemId has a __cmp__ method and it will
normally catch trying to compare to non wxTreeItemId objects, but None gets
turned into NULL by SWIG.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com
http://wxpython.org Java give you jitters?
http://wxpros.com Relax with wxPython!