PyInt_FromLong gives segfault on small numbers (<257)

Discussion in 'Python' started by Marcos Prieto, Aug 5, 2010.

  1. Hi,

    I'm trying to call python (python 2.6) functions from C++ using MS VC+
    + 6.0 and any calls to PyInt_FromLong with numbers below 257 give me
    exceptions, no problems with bigger numbers

    PyObject *pValue;

    pValue = PyInt_FromLong(1L); (or pValue = PyInt_FromLong(1);


    Any ideas of what can I be doing wrong?

    Thanks,

    Marcos.
     
    Marcos Prieto, Aug 5, 2010
    #1
    1. Advertising

  2. On Thu, 5 Aug 2010 05:04:36 -0700 (PDT)
    Marcos Prieto <> wrote:
    > Hi,
    >
    > I'm trying to call python (python 2.6) functions from C++ using MS VC+
    > + 6.0 and any calls to PyInt_FromLong with numbers below 257 give me
    > exceptions, no problems with bigger numbers
    >
    > PyObject *pValue;
    >
    > pValue = PyInt_FromLong(1L); (or pValue = PyInt_FromLong(1);


    Have you called Py_Initialize() before?
     
    Antoine Pitrou, Aug 5, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christian Vogel
    Replies:
    2
    Views:
    3,765
    Christian Vogel
    Feb 25, 2004
  2. NevilleDNZ
    Replies:
    1
    Views:
    619
    NevilleDNZ
    Jan 1, 2007
  3. Yandos
    Replies:
    12
    Views:
    5,143
    Pete Becker
    Sep 15, 2005
  4. Andrey Vul
    Replies:
    8
    Views:
    699
    Richard Bos
    Jul 30, 2010
  5. rantingrick
    Replies:
    16
    Views:
    559
    rantingrick
    Jul 17, 2011
Loading...

Share This Page