[egenix-users] segfault in method .pydate() of DateTime

M.-A. Lemburg mal at egenix.com
Fri Jan 27 12:44:15 CET 2012


Szoska, Daniel wrote:
> Hello,
> 
> Python dies with a segmentation fault, can someone reproduce this:
> 
>>>> import mx.DateTime
>>>> mx.DateTime.Date(2012, 1, 1).pydate()
> segmentation fault
> 
> This happens with .pydatetime() and .pytime() too.
> 
> I tried it with Python 2.7.2, egenix-mx-base 3.2.2 under Linux, Max OS 10.7
> and Windows XP.

Thank you for reporting this.

We have done some preliminary tests and it appears to be caused
by the fact that mxDateTime uses a lazy import of the datetime
module to implement interfacing with Python's datetime module
types.

The problem doesn't show up in the tests because the datetime
module's C API is already initialized by the time the .pydate()
(et al.) tests are run.

We will issue a new patch level release to address the problem.

Until then, please use the following trick to force initialization
of the datetime C API in mxDateTime:

# Trick to force initialization of the datetime C API in mxDateTime:
import mx.DateTime
import datetime
mx.DateTime.today() == datetime.date.today()

Background: The comparison causes a forced initialization.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jan 27 2012)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/



More information about the egenix-users mailing list