[wxPython] wxPython Segfault

wxPython Segfault

I'm running
Linux 2.2.19
egcs-2.91.66
wxGTK/wxPython CVS

Output from gdb:
$ gdb "python demo.py" core
Core was generated by `python ./demo.py'.
Program terminated with signal 11, Segmentation violation.
Reading symbols from /lib/libdb.so.3...done.
Reading symbols from /lib/libpthread.so.0...done.
Reading symbols from /lib/libdl.so.2...done.
Reading symbols from /lib/libutil.so.1...done.
Reading symbols from /lib/libm.so.6...done.
Reading symbols from /lib/libc.so.6...done.
Reading symbols from /lib/ld-linux.so.2...done.
Reading symbols from
/usr/lib/python2.0/site-packages/wxPython/wxc.so...done.
Reading symbols from /usr/local/lib/libwx_gtk.so...done.
Reading symbols from /usr/lib/libgtk-1.2.so.0...done.
Reading symbols from /usr/lib/libgdk-1.2.so.0...done.
Reading symbols from /usr/lib/libgmodule-1.2.so.0...done.
Reading symbols from /usr/lib/libgthread-1.2.so.0...done.
Reading symbols from /usr/lib/libglib-1.2.so.0...done.
Reading symbols from /usr/X11R6/lib/libXext.so.6...done.
Reading symbols from /usr/X11R6/lib/libX11.so.6...done.
Reading symbols from /lib/libnss_compat.so.2...done.
Reading symbols from /lib/libnsl.so.1...done.
Reading symbols from /usr/lib/gtk/themes/engines/libnotif.so...done.
Reading symbols from
/usr/lib/python2.0/lib-dynload/stropmodule.so...done.
Reading symbols from
/usr/lib/python2.0/site-packages/wxPython/utilsc.so...done.
Reading symbols from
/usr/lib/python2.0/site-packages/wxPython/htmlc.so...done.
Reading symbols from /usr/lib/python2.0/lib-dynload/cPickle.so...done.
Reading symbols from /usr/lib/python2.0/lib-dynload/cStringIO.so...done.
Reading symbols from
/usr/lib/python2.0/lib-dynload/zlibmodule.so...done.
Reading symbols from /usr/lib/libz.so.1...done.
#0 0x401e27d9 in SWIG_GetPtr (c=0x0, ptr=0xbfffe610, t=0x40299d9f
"_wxEvtHandler_p")
    at src/libpy.c:317
317 if (*c != '_') {
(gdb)

···

-----------------------------
Med vänlig hälsning / Regards

Håkan Olsson, Suntron
suntron@algonet.se

#0 0x401e27d9 in SWIG_GetPtr (c=0x0, ptr=0xbfffe610, t=0x40299d9f
"_wxEvtHandler_p")
    at src/libpy.c:317
317 if (*c != '_') {
(gdb)

Please do a backtrace so we can see how it got to this point.

···

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

Robin Dunn wrote:

> #0 0x401e27d9 in SWIG_GetPtr (c=0x0, ptr=0xbfffe610, t=0x40299d9f
> "_wxEvtHandler_p")
> at src/libpy.c:317
> 317 if (*c != '_') {
> (gdb)

Please do a backtrace so we can see how it got to this point.

(gdb) bt
#0 0x401e27d9 in SWIG_GetPtr (c=0x0, ptr=0xbfffe610, t=0x40299d9f
"_wxEvtHandler_p")
    at src/libpy.c:317
#1 0x401e2c8a in SWIG_GetPtrObj (obj=0x83f6d14, ptr=0xbfffe610,
    type=0x40299d9f "_wxEvtHandler_p") at src/libpy.c:412
#2 0x401eab5d in _wrap_wxEvtHandler_Connect (self=0x0, args=0x83fb1f4,
kwargs=0x83f6fe4)
    at src/gtk/windows.cpp:554
#3 0x80576b2 in call_builtin (func=0x8168fa8, arg=0x83fb1f4,
kw=0x83f6fe4)
    at ../../Python/ceval.c:2644
#4 0x8057608 in PyEval_CallObjectWithKeywords (func=0x8168fa8,
arg=0x83fb1f4, kw=0x83f6fe4)
    at ../../Python/ceval.c:2618
#5 0x80867a0 in builtin_apply (self=0x0, args=0x83f6fbc) at
../../Python/bltinmodule.c:88
#6 0x80576ea in call_builtin (func=0x80c67e0, arg=0x83f6fbc, kw=0x0) at
../../Python/ceval.c:2650
#7 0x8057608 in PyEval_CallObjectWithKeywords (func=0x80c67e0,
arg=0x83f6fbc, kw=0x0)
    at ../../Python/ceval.c:2618
#8 0x8056781 in eval_code2 (co=0x8215910, globals=0x8238e1c,
locals=0x0, args=0x8264c0c,
    argcount=5, kws=0x8264c20, kwcount=0, defs=0x0, defcount=0,
owner=0x8259914)
    at ../../Python/ceval.c:1951
#9 0x80564d8 in eval_code2 (co=0x81ce9d0, globals=0x81ec07c,
locals=0x0, args=0x82a6c20,
    argcount=2, kws=0x82a6c28, kwcount=0, defs=0x0, defcount=0,
owner=0x0)
    at ../../Python/ceval.c:1850
#10 0x80564d8 in eval_code2 (co=0x83985b0, globals=0x81e136c,
locals=0x0, args=0x83f6d98,
    argcount=2, kws=0x83f6da8, kwcount=3, defs=0x81fe2b0, defcount=6,
owner=0x81e152c)
    at ../../Python/ceval.c:1850
#11 0x80579ed in call_function (func=0x81dff94, arg=0x83f6cf4,
kw=0x83f6c8c)
    at ../../Python/ceval.c:2772
#12 0x80575fe in PyEval_CallObjectWithKeywords (func=0x83f6d64,
arg=0x83f6cf4, kw=0x83f6c8c)
    at ../../Python/ceval.c:2616
#13 0x806d843 in PyInstance_New (class=0x81e152c, arg=0x83f6cf4,
kw=0x83f6c8c)
    at ../../Objects/classobject.c:463
#14 0x80576ff in call_builtin (func=0x81e152c, arg=0x83f6cf4,
kw=0x83f6c8c)
    at ../../Python/ceval.c:2653
#15 0x8057608 in PyEval_CallObjectWithKeywords (func=0x81e152c,
arg=0x83f6cf4, kw=0x83f6c8c)
    at ../../Python/ceval.c:2618
#16 0x8056781 in eval_code2 (co=0x8106d48, globals=0x80d33bc,
locals=0x0, args=0x80d84a8,
    argcount=1, kws=0x0, kwcount=0, defs=0x0, defcount=0,
owner=0x83dc6fc)
    at ../../Python/ceval.c:1951
#17 0x80579ed in call_function (func=0x83dc75c, arg=0x80c7b5c, kw=0x0)
    at ../../Python/ceval.c:2772
#18 0x80575fe in PyEval_CallObjectWithKeywords (func=0x80ec91c,
arg=0x80c7b5c, kw=0x0)
    at ../../Python/ceval.c:2616
#19 0x401df968 in __wxStart (args=0x80d8104) at src/helpers.cpp:185
#20 0x80576b2 in call_builtin (func=0x810b950, arg=0x80d8104, kw=0x0) at
../../Python/ceval.c:2644
#21 0x8057608 in PyEval_CallObjectWithKeywords (func=0x810b950,
arg=0x80d8104, kw=0x0)
    at ../../Python/ceval.c:2618
#22 0x8056781 in eval_code2 (co=0x81df2c8, globals=0x81ec07c,
locals=0x0, args=0x83f3610,
    argcount=2, kws=0x0, kwcount=0, defs=0x8361178, defcount=2,
owner=0x8397e64)
    at ../../Python/ceval.c:1951
#23 0x80579ed in call_function (func=0x8397efc, arg=0x80d4d74, kw=0x0)
    at ../../Python/ceval.c:2772
#24 0x80575fe in PyEval_CallObjectWithKeywords (func=0x80c82ec,
arg=0x80d4d74, kw=0x0)
    at ../../Python/ceval.c:2616
---Type <return> to continue, or q <return> to quit---
#25 0x806d843 in PyInstance_New (class=0x83dc6fc, arg=0x80d4d74, kw=0x0)
    at ../../Objects/classobject.c:463
#26 0x80576ff in call_builtin (func=0x83dc6fc, arg=0x80d4d74, kw=0x0) at
../../Python/ceval.c:2653
#27 0x8057608 in PyEval_CallObjectWithKeywords (func=0x83dc6fc,
arg=0x80d4d74, kw=0x0)
    at ../../Python/ceval.c:2618
#28 0x8056781 in eval_code2 (co=0x81078b0, globals=0x80d33bc,
locals=0x0, args=0x80d51d0,
    argcount=0, kws=0x80d51d0, kwcount=0, defs=0x0, defcount=0,
owner=0x0)
    at ../../Python/ceval.c:1951
#29 0x80564d8 in eval_code2 (co=0x80c7bd0, globals=0x80ca184,
locals=0x80ca184, args=0x0,
    argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, owner=0x0) at
../../Python/ceval.c:1850
#30 0x8054537 in PyEval_EvalCode (co=0x80c7bd0, globals=0x80ca184,
locals=0x80ca184)
    at ../../Python/ceval.c:319
#31 0x8065af4 in run_node (n=0x80d31c8, filename=0xbffff268 "./demo.py",
globals=0x80ca184,
    locals=0x80ca184) at ../../Python/pythonrun.c:886
#32 0x8065abd in run_err_node (n=0x80d31c8, filename=0xbffff268
"./demo.py", globals=0x80ca184,
    locals=0x80ca184) at ../../Python/pythonrun.c:874
#33 0x8065a9b in PyRun_FileEx (fp=0x80c6498, filename=0xbffff268
"./demo.py", start=257,
    globals=0x80ca184, locals=0x80ca184, closeit=1) at
../../Python/pythonrun.c:866
#34 0x8065267 in PyRun_SimpleFileEx (fp=0x80c6498, filename=0xbffff268
"./demo.py", closeit=1)
    at ../../Python/pythonrun.c:579
#35 0x8064f1c in PyRun_AnyFileEx (fp=0x80c6498, filename=0xbffff268
"./demo.py", closeit=1)
    at ../../Python/pythonrun.c:459
#36 0x8051a10 in Py_Main (argc=1, argv=0xbffff0a4) at
../../Modules/main.c:289
#37 0x8051556 in main (argc=2, argv=0xbffff0a4) at
../../Modules/python.c:10
(gdb)

···

-----------------------------
Med vänlig hälsning / Regards

Håkan Olsson, Suntron
suntron@algonet.se

gdb:
.
.
#0 0x401e293d in SWIG_GetPtr (c=0x0, ptr=0xbfffe610, t=0x4029a0ff
"_wxEvtHandler_p")
    at src/libpy.c:319
319 if (*c != '_') {
(gdb)

Hi Robin
Maybe this can give you a clue to what the trouble is.
I printed c in libpy.c;SWIG_MakePtr and str in libpy.c;SWIG_GetPtrObj.
In the gdb output above it try to get a pointer of type _wxEvtHandler_p,
but there is no _wxEvtHandler_p in the printout below.
In the last print from SWIG_GetPtrObj str=(null).

SWIGSTATICRUNTIME(void)
SWIG_MakePtr(char *c, const void *ptr, char *type) {
  static char hex[17] = "0123456789abcdef";
  unsigned long p, s;
  char result[24], *r;
  char *tmp = c; /* TEST */
  r = result;
  p = (unsigned long) ptr;
  if (p > 0) {
    while (p > 0) {
      s = p & 0xf;
      *(r++) = hex[s];
      p = p >> 4;
    }
    *r = '_';
    while (r >= result)
      *(c++) = *(r--);
    strcpy (c, type);
  } else {
    strcpy (c, "NULL");
  }
  printf("SWIG_MakePtr: c=%s\n", tmp); /* TEST */
}

SWIGSTATICRUNTIME(char *)
SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type) {
  PyObject *sobj = obj;
  char *str;
  if (!PyString_Check(obj)) {
      if (!PyInstance_Check(obj) || !(sobj =
PyObject_GetAttrString(obj,"this")))
          return "";
      // PyObject_GetAttrString increases sobj refcout !
      Py_DECREF(sobj);
  }
  str = PyString_AsString(sobj);
  /* + TEST */
  /* printf("Len(str)=%d\n", strlen(str)); */
  printf("SWIG_GetPtrObj: str=%s\n", str);
  /* - TEST */
  return SWIG_GetPtr(str,ptr,type);
}

$ ./demo.py
SWIG_MakePtr: c=_4084a5ac_wxAcceleratorTable_p
SWIG_MakePtr: c=_8151f60_wxFont_p
SWIG_MakePtr: c=_8152020_wxFont_p
SWIG_MakePtr: c=_81520a8_wxFont_p
SWIG_MakePtr: c=_8152130_wxFont_p
SWIG_MakePtr: c=_81521b8_wxPen_p
SWIG_MakePtr: c=_8152228_wxPen_p
SWIG_MakePtr: c=_8152298_wxPen_p
SWIG_MakePtr: c=_8152308_wxPen_p
SWIG_MakePtr: c=_8152378_wxPen_p
SWIG_MakePtr: c=_81523e8_wxPen_p
SWIG_MakePtr: c=_8152458_wxPen_p
SWIG_MakePtr: c=_81524c8_wxPen_p
SWIG_MakePtr: c=_8152538_wxPen_p
SWIG_MakePtr: c=_81525a8_wxPen_p
SWIG_MakePtr: c=_8152618_wxBrush_p
SWIG_MakePtr: c=_81526a0_wxBrush_p
SWIG_MakePtr: c=_8152728_wxBrush_p
SWIG_MakePtr: c=_81527b0_wxBrush_p
SWIG_MakePtr: c=_8152838_wxBrush_p
SWIG_MakePtr: c=_81528c0_wxBrush_p
SWIG_MakePtr: c=_8152948_wxBrush_p
SWIG_MakePtr: c=_81529d0_wxBrush_p
SWIG_MakePtr: c=_8152a58_wxBrush_p
SWIG_MakePtr: c=_8152ae0_wxBrush_p
SWIG_MakePtr: c=_8152b68_wxColour_p
SWIG_MakePtr: c=_8152b80_wxColour_p
SWIG_MakePtr: c=_8152b98_wxColour_p
SWIG_MakePtr: c=_8152bb0_wxColour_p
SWIG_MakePtr: c=_8152bc8_wxColour_p
SWIG_MakePtr: c=_8152be0_wxColour_p
SWIG_MakePtr: c=_8152bf8_wxColour_p
SWIG_MakePtr: c=_8150018_wxCursor_p
SWIG_MakePtr: c=_8152c30_wxCursor_p
SWIG_MakePtr: c=_8152c60_wxCursor_p
SWIG_MakePtr: c=_4084a59c_wxBitmap_p
SWIG_MakePtr: c=_4084a58c_wxIcon_p
SWIG_MakePtr: c=_4084a580_wxCursor_p
SWIG_MakePtr: c=_4084a570_wxPen_p
SWIG_MakePtr: c=_4084a560_wxBrush_p
SWIG_MakePtr: c=_4084a530_wxPalette_p
SWIG_MakePtr: c=_4084a550_wxFont_p
SWIG_MakePtr: c=_4084a540_wxColour_p
SWIG_MakePtr: c=_8151f10_wxFontList_p
SWIG_MakePtr: c=_8151ee8_wxPenList_p
SWIG_MakePtr: c=_814ffd0_wxColourDatabase_p
SWIG_MakePtr: c=_4034f544_wxDataFormat_p
SWIG_MakePtr: c=_81574a8_wxClipboard_p
SWIG_MakePtr: c=_40850140_wxValidator_p
SWIG_MakePtr: c=_4084e120_wxImage_p
SWIG_MakePtr: c=_4084a520_wxPoint_p
SWIG_MakePtr: c=_4084a528_wxSize_p
SWIG_MakePtr: c=_81075a0_wxPyApp_p
SWIG_MakePtr: c=_829aad0_wxImage_p
SWIG_GetPtrObj: str=_829aad0_wxImage_p
SWIG_MakePtr: c=_838e8c8_wxBitmap_p
SWIG_GetPtrObj: str=_829aad0_wxImage_p
SWIG_GetPtrObj: str=_838e8c8_wxBitmap_p
SWIG_GetPtrObj: str=_838e8c8_wxBitmap_p
SWIG_MakePtr: c=_83f9e08_wxFrame_p
SWIG_GetPtrObj: str=(null)
Segmenteringsfel (core dumped)

gdb backtrace:

(gdb) bt
#0 0x401e293d in SWIG_GetPtr (c=0x0, ptr=0xbfffe610, t=0x4029a0ff
"_wxEvtHandler_p")
    at src/libpy.c:319
#1 0x401e2dfd in SWIG_GetPtrObj (obj=0x83f6f04, ptr=0xbfffe610,
    type=0x4029a0ff "_wxEvtHandler_p") at src/libpy.c:418
#2 0x401eaccd in _wrap_wxEvtHandler_Connect (self=0x0, args=0x83fb3e4,
kwargs=0x83f71d4)
    at src/gtk/windows.cpp:554
#3 0x80576b2 in call_builtin (func=0x8168fa8, arg=0x83fb3e4,
kw=0x83f71d4)
    at ../../Python/ceval.c:2644
#4 0x8057608 in PyEval_CallObjectWithKeywords (func=0x8168fa8,
arg=0x83fb3e4, kw=0x83f71d4)
    at ../../Python/ceval.c:2618
#5 0x80867a0 in builtin_apply (self=0x0, args=0x83f71ac) at
../../Python/bltinmodule.c:88
#6 0x80576ea in call_builtin (func=0x80c67e0, arg=0x83f71ac, kw=0x0) at
../../Python/ceval.c:2650
#7 0x8057608 in PyEval_CallObjectWithKeywords (func=0x80c67e0,
arg=0x83f71ac, kw=0x0)
    at ../../Python/ceval.c:2618
#8 0x8056781 in eval_code2 (co=0x8215910, globals=0x8238e1c,
locals=0x0, args=0x8264be4,
    argcount=5, kws=0x8264bf8, kwcount=0, defs=0x0, defcount=0,
owner=0x82598ec)
    at ../../Python/ceval.c:1951
#9 0x80564d8 in eval_code2 (co=0x81ce9d0, globals=0x81ec07c,
locals=0x0, args=0x82a6bf8,
    argcount=2, kws=0x82a6c00, kwcount=0, defs=0x0, defcount=0,
owner=0x0)
    at ../../Python/ceval.c:1850
#10 0x80564d8 in eval_code2 (co=0x83987a0, globals=0x81e136c,
locals=0x0, args=0x83f6f88,
    argcount=2, kws=0x83f6f98, kwcount=3, defs=0x81fe2b0, defcount=6,
owner=0x81e152c)
    at ../../Python/ceval.c:1850
#11 0x80579ed in call_function (func=0x81dff94, arg=0x83f6ee4,
kw=0x83f6e7c)
    at ../../Python/ceval.c:2772
#12 0x80575fe in PyEval_CallObjectWithKeywords (func=0x83f6f54,
arg=0x83f6ee4, kw=0x83f6e7c)
    at ../../Python/ceval.c:2616
#13 0x806d843 in PyInstance_New (class=0x81e152c, arg=0x83f6ee4,
kw=0x83f6e7c)
    at ../../Objects/classobject.c:463
#14 0x80576ff in call_builtin (func=0x81e152c, arg=0x83f6ee4,
kw=0x83f6e7c)
    at ../../Python/ceval.c:2653
#15 0x8057608 in PyEval_CallObjectWithKeywords (func=0x81e152c,
arg=0x83f6ee4, kw=0x83f6e7c)
    at ../../Python/ceval.c:2618
#16 0x8056781 in eval_code2 (co=0x8106d48, globals=0x80d33bc,
locals=0x0, args=0x80d84a8,
    argcount=1, kws=0x0, kwcount=0, defs=0x0, defcount=0,
owner=0x83dc8ec)
    at ../../Python/ceval.c:1951
#17 0x80579ed in call_function (func=0x83dc94c, arg=0x80c7b5c, kw=0x0)
    at ../../Python/ceval.c:2772
#18 0x80575fe in PyEval_CallObjectWithKeywords (func=0x80ec91c,
arg=0x80c7b5c, kw=0x0)
    at ../../Python/ceval.c:2616
#19 0x401dfabc in __wxStart (args=0x80d8104) at src/helpers.cpp:185
#20 0x80576b2 in call_builtin (func=0x810b950, arg=0x80d8104, kw=0x0) at
../../Python/ceval.c:2644
#21 0x8057608 in PyEval_CallObjectWithKeywords (func=0x810b950,
arg=0x80d8104, kw=0x0)
    at ../../Python/ceval.c:2618
#22 0x8056781 in eval_code2 (co=0x81df2c8, globals=0x81ec07c,
locals=0x0, args=0x83f3800,
    argcount=2, kws=0x0, kwcount=0, defs=0x8361368, defcount=2,
owner=0x8398054)
    at ../../Python/ceval.c:1951
#23 0x80579ed in call_function (func=0x83980ec, arg=0x80d4d74, kw=0x0)
    at ../../Python/ceval.c:2772
#24 0x80575fe in PyEval_CallObjectWithKeywords (func=0x80c82ec,
arg=0x80d4d74, kw=0x0)
    at ../../Python/ceval.c:2616
#25 0x806d843 in PyInstance_New (class=0x83dc8ec, arg=0x80d4d74, kw=0x0)
    at ../../Objects/classobject.c:463
#26 0x80576ff in call_builtin (func=0x83dc8ec, arg=0x80d4d74, kw=0x0) at
../../Python/ceval.c:2653
#27 0x8057608 in PyEval_CallObjectWithKeywords (func=0x83dc8ec,
arg=0x80d4d74, kw=0x0)
    at ../../Python/ceval.c:2618
#28 0x8056781 in eval_code2 (co=0x81078b0, globals=0x80d33bc,
locals=0x0, args=0x80d51d0,
    argcount=0, kws=0x80d51d0, kwcount=0, defs=0x0, defcount=0,
owner=0x0)
    at ../../Python/ceval.c:1951
#29 0x80564d8 in eval_code2 (co=0x80c7bd0, globals=0x80ca184,
locals=0x80ca184, args=0x0,
    argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, owner=0x0) at
../../Python/ceval.c:1850
#30 0x8054537 in PyEval_EvalCode (co=0x80c7bd0, globals=0x80ca184,
locals=0x80ca184)
    at ../../Python/ceval.c:319
#31 0x8065af4 in run_node (n=0x80d31c8, filename=0xbffff268 "./demo.py",
globals=0x80ca184,
    locals=0x80ca184) at ../../Python/pythonrun.c:886
#32 0x8065abd in run_err_node (n=0x80d31c8, filename=0xbffff268
"./demo.py", globals=0x80ca184,
    locals=0x80ca184) at ../../Python/pythonrun.c:874
#33 0x8065a9b in PyRun_FileEx (fp=0x80c6498, filename=0xbffff268
"./demo.py", start=257,
    globals=0x80ca184, locals=0x80ca184, closeit=1) at
../../Python/pythonrun.c:866
#34 0x8065267 in PyRun_SimpleFileEx (fp=0x80c6498, filename=0xbffff268
"./demo.py", closeit=1)
    at ../../Python/pythonrun.c:579
#35 0x8064f1c in PyRun_AnyFileEx (fp=0x80c6498, filename=0xbffff268
"./demo.py", closeit=1)
    at ../../Python/pythonrun.c:459
#36 0x8051a10 in Py_Main (argc=1, argv=0xbffff0a4) at
../../Modules/main.c:289
#37 0x8051556 in main (argc=2, argv=0xbffff0a4) at
../../Modules/python.c:10
(gdb)

···

--
Med vänlig hälsning / Regards

Håkan Olsson, Suntron
suntron@algonet.se

Maybe this can give you a clue to what the trouble is.
I printed c in libpy.c;SWIG_MakePtr and str in libpy.c;SWIG_GetPtrObj.
In the gdb output above it try to get a pointer of type _wxEvtHandler_p,
but there is no _wxEvtHandler_p in the printout below.

That shouldn't matter, it works with a class derived from wxEvtHandler too.

In the last print from SWIG_GetPtrObj str=(null).

I don't see how this should ever be NULL unless the .this attribute of the
object has gotten changed to something other than a string. If you change
SWIG_GetPtrObj like this then it should at least prevent the crash and may
give you a clue where the problem is really coming from.

SWIGSTATICRUNTIME(char *)
SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type) {
  PyObject *sobj = obj;
  char *str;
  if (!PyString_Check(obj)) {
      if (!PyInstance_Check(obj) || !(sobj =
PyObject_GetAttrString(obj,"this")))
          return "";
      // PyObject_GetAttrString increases sobj refcout !
      Py_DECREF(sobj);
  }
  str = PyString_AsString(sobj);
  if (str == NULL)
      return "";
  return SWIG_GetPtr(str,ptr,type);
}

···

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

Robin Dunn wrote:

object has gotten changed to something other than a string. If you change
SWIG_GetPtrObj like this then it should at least prevent the crash and may
give you a clue where the problem is really coming from.

SWIGSTATICRUNTIME(char *)
SWIG_GetPtrObj(PyObject *obj, void **ptr, char *type) {
  PyObject *sobj = obj;
  char *str;
  if (!PyString_Check(obj)) {
      if (!PyInstance_Check(obj) || !(sobj =
PyObject_GetAttrString(obj,"this")))
          return "";
      // PyObject_GetAttrString increases sobj refcout !
      Py_DECREF(sobj);
  }
  str = PyString_AsString(sobj);
  if (str == NULL)
      return "";
  return SWIG_GetPtr(str,ptr,type);
}

This is what I get now.
(SWIG_GetPtrObj... is my test print.)

$ ./demo.py
SWIG_GetPtrObj: str=_829aad0_wxImage_p
SWIG_GetPtrObj: str=_829aad0_wxImage_p
SWIG_GetPtrObj: str=_838e8c8_wxBitmap_p
SWIG_GetPtrObj: str=_838e8c8_wxBitmap_p
SWIG_GetPtrObj: str=(null)
Traceback (most recent call last):
  File "./demo.py", line 4, in ?
    Main.main()
  File "./Main.py", line 477, in main
    app = MyApp(0)
  File "/usr/lib/python2.0/site-packages/wxPython/wx.py", line 1607, in
__init__
    _wxStart(self.OnInit)
  File "./Main.py", line 441, in OnInit
    duration=2000, callback=self.AfterSplash)
  File "/usr/lib/python2.0/site-packages/wxPython/lib/splashscreen.py",
line 62, in __init__
    EVT_LEFT_DOWN(self, self.OnMouseClick)
  File "/usr/lib/python2.0/site-packages/wxPython/wx.py", line 972, in
EVT_LEFT_DOWN
    win.Connect(-1, -1, wxEVT_LEFT_DOWN, func)
  File "/usr/lib/python2.0/site-packages/wxPython/windows.py", line 52,
in Connect
    val = apply(windowsc.wxEvtHandler_Connect,(self,) + _args, _kwargs)
TypeError: Type error in argument 1 of wxEvtHandler_Connect. Expected
_wxEvtHandler_p.
SWIG_GetPtrObj: str=_838e8c8_wxBitmap_p

(gdb) bt
#0 0x40540e9c in wxCommandEvent::~wxCommandEvent () from
/usr/local/lib/libwx_gtk.so
#1 0x401ead1a in _wrap_wxEvtHandler_Connect (self=0x38306539,
args=0xffffffff, kwargs=0xffffffff)
    at src/gtk/windows.cpp:573
#2 0x401eae33 in _wrap_wxEvtHandler_Disconnect (self=0x0,
args=0x83fb3e4, kwargs=0x83f71d4)
    at src/gtk/windows.cpp:602
#3 0x80576b2 in call_builtin (func=0x8168fa8, arg=0x83fb3e4,
kw=0x83f71d4)
    at ../../Python/ceval.c:2644
#4 0x8057608 in PyEval_CallObjectWithKeywords (func=0x8168fa8,
arg=0x83fb3e4, kw=0x83f71d4)
    at ../../Python/ceval.c:2618
#5 0x80867a0 in builtin_apply (self=0x0, args=0x83f71ac) at
../../Python/bltinmodule.c:88
#6 0x80576ea in call_builtin (func=0x80c67e0, arg=0x83f71ac, kw=0x0) at
../../Python/ceval.c:2650
#7 0x8057608 in PyEval_CallObjectWithKeywords (func=0x80c67e0,
arg=0x83f71ac, kw=0x0)
    at ../../Python/ceval.c:2618
#8 0x8056781 in eval_code2 (co=0x8215910, globals=0x8238e1c,
locals=0x0, args=0x8264be4,
    argcount=5, kws=0x8264bf8, kwcount=0, defs=0x0, defcount=0,
owner=0x82598ec)
    at ../../Python/ceval.c:1951
#9 0x80564d8 in eval_code2 (co=0x81ce9d0, globals=0x81ec07c,
locals=0x0, args=0x82a6bf8,
    argcount=2, kws=0x82a6c00, kwcount=0, defs=0x0, defcount=0,
owner=0x0)
    at ../../Python/ceval.c:1850
#10 0x80564d8 in eval_code2 (co=0x83987a0, globals=0x81e136c,
locals=0x0, args=0x83f6f88,
    argcount=2, kws=0x83f6f98, kwcount=3, defs=0x81fe2b0, defcount=6,
owner=0x81e152c)
    at ../../Python/ceval.c:1850
#11 0x80579ed in call_function (func=0x81dff94, arg=0x83f6ee4,
kw=0x83f6e7c)
    at ../../Python/ceval.c:2772
#12 0x80575fe in PyEval_CallObjectWithKeywords (func=0x83f6f54,
arg=0x83f6ee4, kw=0x83f6e7c)
    at ../../Python/ceval.c:2616
#13 0x806d843 in PyInstance_New (class=0x81e152c, arg=0x83f6ee4,
kw=0x83f6e7c)
    at ../../Objects/classobject.c:463
#14 0x80576ff in call_builtin (func=0x81e152c, arg=0x83f6ee4,
kw=0x83f6e7c)
    at ../../Python/ceval.c:2653
#15 0x8057608 in PyEval_CallObjectWithKeywords (func=0x81e152c,
arg=0x83f6ee4, kw=0x83f6e7c)
    at ../../Python/ceval.c:2618
#16 0x8056781 in eval_code2 (co=0x8106d48, globals=0x80d33bc,
locals=0x0, args=0x80d84a8,
    argcount=1, kws=0x0, kwcount=0, defs=0x0, defcount=0,
owner=0x83dc8ec)
    at ../../Python/ceval.c:1951
#17 0x80579ed in call_function (func=0x83dc94c, arg=0x80c7b5c, kw=0x0)
    at ../../Python/ceval.c:2772
#18 0x80575fe in PyEval_CallObjectWithKeywords (func=0x80ec91c,
arg=0x80c7b5c, kw=0x0)
    at ../../Python/ceval.c:2616
#19 0x401dfadc in __wxStart (args=0x80d8104) at
/usr/local/include/wx/list.h:200
#20 0x80576b2 in call_builtin (func=0x810b950, arg=0x80d8104, kw=0x0) at
../../Python/ceval.c:2644
#21 0x8057608 in PyEval_CallObjectWithKeywords (func=0x810b950,
arg=0x80d8104, kw=0x0)
    at ../../Python/ceval.c:2618
#22 0x8056781 in eval_code2 (co=0x81df2c8, globals=0x81ec07c,
locals=0x0, args=0x83f3800,
    argcount=2, kws=0x0, kwcount=0, defs=0x8361368, defcount=2,
owner=0x8398054)
    at ../../Python/ceval.c:1951
#23 0x80579ed in call_function (func=0x83980ec, arg=0x80d4d74, kw=0x0)
    at ../../Python/ceval.c:2772
#24 0x80575fe in PyEval_CallObjectWithKeywords (func=0x80c82ec,
arg=0x80d4d74, kw=0x0)
    at ../../Python/ceval.c:2616
#25 0x806d843 in PyInstance_New (class=0x83dc8ec, arg=0x80d4d74, kw=0x0)
    at ../../Objects/classobject.c:463
#26 0x80576ff in call_builtin (func=0x83dc8ec, arg=0x80d4d74, kw=0x0) at
../../Python/ceval.c:2653
#27 0x8057608 in PyEval_CallObjectWithKeywords (func=0x83dc8ec,
arg=0x80d4d74, kw=0x0)
    at ../../Python/ceval.c:2618
#28 0x8056781 in eval_code2 (co=0x81078b0, globals=0x80d33bc,
locals=0x0, args=0x80d51d0,
    argcount=0, kws=0x80d51d0, kwcount=0, defs=0x0, defcount=0,
owner=0x0)
    at ../../Python/ceval.c:1951
#29 0x80564d8 in eval_code2 (co=0x80c7bd0, globals=0x80ca184,
locals=0x80ca184, args=0x0,
    argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, owner=0x0) at
../../Python/ceval.c:1850
#30 0x8054537 in PyEval_EvalCode (co=0x80c7bd0, globals=0x80ca184,
locals=0x80ca184)
    at ../../Python/ceval.c:319
#31 0x8065af4 in run_node (n=0x80d31c8, filename=0xbffff268 "./demo.py",
globals=0x80ca184,
    locals=0x80ca184) at ../../Python/pythonrun.c:886
#32 0x8065abd in run_err_node (n=0x80d31c8, filename=0xbffff268
"./demo.py", globals=0x80ca184,
    locals=0x80ca184) at ../../Python/pythonrun.c:874
#33 0x8065a9b in PyRun_FileEx (fp=0x80c6498, filename=0xbffff268
"./demo.py", start=257,
    globals=0x80ca184, locals=0x80ca184, closeit=1) at
../../Python/pythonrun.c:866
#34 0x8065267 in PyRun_SimpleFileEx (fp=0x80c6498, filename=0xbffff268
"./demo.py", closeit=1)
    at ../../Python/pythonrun.c:579
#35 0x8064f1c in PyRun_AnyFileEx (fp=0x80c6498, filename=0xbffff268
"./demo.py", closeit=1)
    at ../../Python/pythonrun.c:459
#36 0x8051a10 in Py_Main (argc=1, argv=0xbffff0a4) at
../../Modules/main.c:289
#37 0x8051556 in main (argc=2, argv=0xbffff0a4) at
../../Modules/python.c:10
(gdb)

···

--
Med vänlig hälsning / Regards

Håkan Olsson, Suntron
suntron@algonet.se

  File "/usr/lib/python2.0/site-packages/wxPython/lib/splashscreen.py",
line 62, in __init__
    EVT_LEFT_DOWN(self, self.OnMouseClick)
  File "/usr/lib/python2.0/site-packages/wxPython/wx.py", line 972, in
EVT_LEFT_DOWN
    win.Connect(-1, -1, wxEVT_LEFT_DOWN, func)
  File "/usr/lib/python2.0/site-packages/wxPython/windows.py", line 52,
in Connect
    val = apply(windowsc.wxEvtHandler_Connect,(self,) + _args, _kwargs)
TypeError: Type error in argument 1 of wxEvtHandler_Connect. Expected
_wxEvtHandler_p.

Looks like the splashscreen's wxFrame constructor is failing somehow. Try
this and let me know what is printed:

from wxPython.wx import *

app = wxPySimpleApp()
frame = wxFrame(None, -1, "Test Frame", size=(300, 200))
print frame.this
frame.Show(true)
app.MainLoop()

Also since you are building your own from CVS you may want to reconfigure
wxGTK with --enable-debug and then rebuild wxGTK and wxPython. This will
add __WXDEBUG__ to the compile flags and will enable some debugging code
that may help.

BTW, are you using the CVS trunk or the WX_2_2_BRANCH? How recent was your
checkout? If you want to get the same as what I just released for 2.3.0 you
can use the wxPy_2_3_0 tag.

···

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

Robin Dunn wrote:

BTW, are you using the CVS trunk or the WX_2_2_BRANCH? How recent was your
checkout? If you want to get the same as what I just released for 2.3.0 you
can use the wxPy_2_3_0 tag.

I followed your suggestion and made a checkout (not update) of the
wxPy_2_3_0 release, and now it works.

Thank's for your time.

···

--
Med vänlig hälsning / Regards

Håkan Olsson, Suntron
suntron@algonet.se