[wxPython] if wxDateTime == None causes segfault

Can someone explain why when comparing a wxDateTime to None python
segfaults? This is on wxPython 2.3.2.1, Python 2.1.2, Debian GNU/Linux
(sid).

Here is a (very) simple test script:

## begin Python code

from wxPython.wx import *

if wxDateTime_Today() == None:
  print "I made it!"

## end Python code

here is what I get when running python from gdb:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 1490)]
0x40a486a9 in wxDateTime___cmp__ (self=0x81f57b0, other=@0x0)
    at /usr/include/wx/datetime.inl:138
138 return m_time;

Thanks!

···

--
Jade Meskill <jade.meskill@libertydistribution.com>

You should rather check whether
wxDateTime_Today() is None:
  print "This makes more sense"

Horst

···

On Fri, 29 Mar 2002 07:11, Jade Meskill wrote:

if wxDateTime_Today() == None:
  print "I made it!"

Horst Herb wrote:

You should rather check whether
wxDateTime_Today() is None:
        print "This makes more sense"

Quite true, since rich comparisons were added, the == None construct
doesn't work reliably. However, it shouldn't segfault either. I supect a
problem with mxDateTime.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                        
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Can someone explain why when comparing a wxDateTime to None python
segfaults? This is on wxPython 2.3.2.1, Python 2.1.2, Debian GNU/Linux
(sid).

This is a bug, which I'll fix.

Here is a (very) simple test script:

## begin Python code

from wxPython.wx import *

if wxDateTime_Today() == None:
print "I made it!"

You can work around it like this:

if wxDateTime_Today() is None:
     print "I made it!"

So you're testing object identity rather than equality.

···

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