C extension and long ints

Michele Campeotto micampe at f2s.com
Wed Aug 22 08:45:57 EDT 2001


Hi, I have a Gtk+ widget wrapped in a Python extension and I need to
pass long integers to some function. The wrapper is generated with the
scripts found in PyGtk and I get an OverflowError when passing a long to
my functions (which is correct because ParseTuple is called with "O!ii").

  Then I have tried to fix it manually and I have done:

    int margin;
    long mask1, mask2;
    PyObject *m;
    PyObject *sci;

    if (!PyArg_ParseTuple(args, "O!iO:gtk_scintilla_set_margin_mask_n", &PyGtk_Type, &sci, &margin, &m))
        return NULL;
    mask1 = PyInt_AsLong(m);
    mask2 = PyLong_AsLong(m);

  but both mask1 and mask2 are always -1...

  What am I doing wrong? Can this be done automatically with the code
generator?
[ix86 Red Hat Linux 7.1 + Ximian Gnome 1.4]

  Thanks in advance,
  Michele

-- 

  -- Michele  -  www.moleskine.f2s.com

  "Your mouse has moved, you must restart
   Windows to see the changes. Restart now?
                  [ Ok ]"







More information about the Python-list mailing list