This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author themoken
Recipients themoken
Date 2009-05-23.02:10:22
SpamBayes Score 1.44329e-15
Marked as misclassified No
Message-id <>
I have some code that gets a Pycurses window object, grabs the standard
ncurses WINDOW* out of it and proceeds to use that as usual. Works great
on Linux. Segfaults on FreeBSD/amd64.

static PyObject * mvw(PyObject *self, PyObject *args)
    PyObject *window;
    WINDOW *win;
    int y, x, width, rep_len, end_len, ret;
    char *message, *rep, *end;

    const char *m_enc, *r_enc, *e_enc;
    if(!PyArg_ParseTuple(args, "Oiiietetet", 
                &window, &y, &x, &width, &m_enc, &message,
                &r_enc, &rep, &e_enc, &end))
            return NULL;

    if (window != Py_None)
        win = ((PyCursesWindowObject *)window)->win;
        win = NULL;

Very simple. After this runs, `win` should be a standard curses window.
As noted, this works just fine in Linux regardless of architecture and
I'm sure that I'm passing a correct object type. (Tangentially, the
window check macro in py_curses.h -- PyCursesWindow_Check(v) -- also
segfaults, but I haven't tested that on Linux).

The subsequent `win` is non-NULL, but when I attempt to actually use it,
even for a simple `mvwaddch(win, 0, 0, '?');`, the program segfaults on

Other Notes: If I just use curses from Python (i.e. without a C
extension), it works as expected. I've attached this basic, working
test. This leads me to believe that the ncurses library is ok, and that
the majority of the curses binding is probably ok.

Also, I'm not sure if there is a better (more pythonic) way to get to
the WINDOW object, I just looked at the struct in py_curses.h to grab it
and it worked, so I didn't give it a second thought until now. I also
don't know how to verify that the pointer points to a curses WINDOW, but
I do know that the pointer address looks ok.

I can whip up a non-working test case on request, but I'm not sure the
best way to include the extension. The full source for the extension and
the program using it at ( particularly:;a=blob;f=canto/widecurse.c;h=d8a259a66c85f5fa87d52045a643fc81beec8017;hb=HEAD

I'm running FreeBSD 8-CURRENT, but the code doesn't work on 7.2-STABLE
either. This is Python 2.5.4 and pyncurses 0.3 both built from source
out of ports as of May 20th.
Date User Action Args
2009-05-23 02:10:29themokensetrecipients: + themoken
2009-05-23 02:10:28themokensetmessageid: <>
2009-05-23 02:10:25themokenlinkissue6091 messages
2009-05-23 02:10:23themokencreate