Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Creating a datetime object from a C Extention

Reply
Thread Tools

Creating a datetime object from a C Extention

 
 
Gerhard Schmidt
Guest
Posts: n/a
 
      11-30-2009
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: http://www.velocityreviews.com/forums/(E-Mail Removed) | 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

iQCVAwUBSxOFLwzx22nOTJQRAQo7GAP6Ay95f8gBCdJcu8dxCL C6e5s3aMf/RLeF
QREaW38VnPv/rMd7d3YZu+87lwGlXgRaX8cihRgeQFxZrheDilMIioftragDQm wK
6waNA+eMPVWckPFT498Aw6UFHMr+QeGWB/OnKwwx72GpAV0huZErA8LWY/WrrIFc
2WitfbWSYww=
=RX9e
-----END PGP SIGNATURE-----

 
Reply With Quote
 
 
 
 
Martin v. L÷wis
Guest
Posts: n/a
 
      11-30-2009
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [2.4.4] creating a datetime.datetime from an XML xs:dateTime skip@pobox.com Python 2 01-06-2009 01:31 PM
[2.4.4] creating a datetime.datetime from an XML xs:dateTime Martin Python 0 12-27-2008 08:08 PM
mx.DateTime to datetime.datetime mp Python 1 07-28-2006 10:57 PM
datetime: .datetime-.datetime = .timedelta, .time-.time=TypeError ? Christos TZOTZIOY Georgiou Python 3 09-13-2003 10:44 AM
RE: datetime: .datetime-.datetime = .timedelta, .time-.time=TypeError ? Tim Peters Python 0 09-09-2003 12:57 AM



Advertisments