Creating a datetime object from a C Extention

Discussion in 'Python' started by Gerhard Schmidt, Nov 30, 2009.

  1. HI,

    I'm writing a python C Extension and need to create datetime objects but
    when I call
    value = PyDateTime_FromDateAndTime(ti->tm_year+1900, ti->tm_mon,
    ti->tm_mday, ti->tm_hour, ti->tm_min, ti->tm_sec, u);
    I get an SegFault.

    ti = {tm_sec = 25, tm_min = 37, tm_hour = 8, tm_mday = 30, tm_mon = 10,
    tm_year = 109, tm_wday = 1, tm_yday = 333, tm_isdst = 0,
    tm_gmtoff = 0, tm_zone = 0x800fd20c8 "UTC"}
    u = 0

    Is there an Dokumentation or example code HowTo create a datetime object
    from a C Extension.

    Regards
    Estartu

    --
    ----------------------------------------------------------------------------
    Gerhard Schmidt | http://www.augusta.de/~estartu/ |
    Fischbachweg 3 | | PGP Public Key
    86856 Hiltenfingen | JabberID: | auf Anfrage/
    Tel: 08232 77 36 4 | IRCNET: Estartu | on request
    Fax: 08232 77 36 3 | |


    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.10 (FreeBSD)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iQCVAwUBSxOFLwzx22nOTJQRAQo7GAP6Ay95f8gBCdJcu8dxCLC6e5s3aMf/RLeF
    QREaW38VnPv/rMd7d3YZu+87lwGlXgRaX8cihRgeQFxZrheDilMIioftragDQmwK
    6waNA+eMPVWckPFT498Aw6UFHMr+QeGWB/OnKwwx72GpAV0huZErA8LWY/WrrIFc
    2WitfbWSYww=
    =RX9e
    -----END PGP SIGNATURE-----
    Gerhard Schmidt, Nov 30, 2009
    #1
    1. Advertising

  2. > I'm writing a python C Extension and need to create datetime objects but
    > when I call
    > value = PyDateTime_FromDateAndTime(ti->tm_year+1900, ti->tm_mon,
    > ti->tm_mday, ti->tm_hour, ti->tm_min, ti->tm_sec, u);
    > I get an SegFault.
    >
    > ti = {tm_sec = 25, tm_min = 37, tm_hour = 8, tm_mday = 30, tm_mon = 10,
    > tm_year = 109, tm_wday = 1, tm_yday = 333, tm_isdst = 0,
    > tm_gmtoff = 0, tm_zone = 0x800fd20c8 "UTC"}
    > u = 0
    >
    > Is there an Dokumentation or example code HowTo create a datetime object
    > from a C Extension.


    You need to put PyDateTime_IMPORT; into your module's init function.

    HTH,
    Martin
    Martin v. Löwis, Nov 30, 2009
    #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. Christos TZOTZIOY Georgiou
    Replies:
    3
    Views:
    691
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  2. Tim Peters
    Replies:
    0
    Views:
    524
    Tim Peters
    Sep 9, 2003
  3. mp
    Replies:
    1
    Views:
    378
    John Machin
    Jul 28, 2006
  4. Martin
    Replies:
    0
    Views:
    329
    Martin
    Dec 27, 2008
  5. Replies:
    2
    Views:
    745
    M.-A. Lemburg
    Jan 6, 2009
Loading...

Share This Page