wx 2.9.5: Problem with DatePickerCtrl and Locale

Hello Group,

i updated wxpython from 2.9.4 to 2.9.5 (msw classic). Now I get the following error when starting my app:

File “C:\Program Files (x86)\Python27\lib\site-packages\wx-2.9.5-msw\wx_controls.py”, line 6523, in init
controls.DatePickerCtrl_swiginit(self,controls.new_DatePickerCtrl(*args, **kwargs))
PyAssertionError: C++ assertion “strcmp(setlocale(LC_ALL, NULL), “C”) == 0” failed at …..\src\common\intl.cpp(1450) in wxLocale::GetInfo(): You probably called setlocale() directly instead of using wxLocale and now there is a mismatch between C/C++ and Windows locale.

I don’t use any locale settings/function in my program. So is it a bug in 2.9.5 (because in 2.9.4 it worked)?

Torsten wrote:

Hello Group,

i updated wxpython from 2.9.4 to 2.9.5 (msw classic). Now I get the
following error when starting my app:

Do you also get it with nothing but a "import wx"?

    File "C:\Program Files
    (x86)\Python27\lib\site-packages\wx-2.9.5-msw\wx\_controls.py", line
    6523, in __init__

    _controls_.DatePickerCtrl_swiginit(self,_controls_.new_DatePickerCtrl(*args,
    **kwargs))

    PyAssertionError: C++ assertion "strcmp(setlocale(LC_ALL, NULL),
    "C") == 0" failed at ..\..\src\common\intl.cpp(1450) in
    wxLocale::GetInfo(): You probably called setlocale() directly
    instead of using wxLocale and now there is a mismatch between C/C++
    and Windows locale.

I don't use any locale settings/function in my program. So is it a bug
in 2.9.5 (because in 2.9.4 it worked)?

There is some code in wx/core.py that reads the locale, but it doesn't set it. Also, it's been there forever.

Probably what changed is that the assertion was added which then revealed a problem that has been there for a while. Be sure that any other modules that are being imported are not setting the locale, and you may also want to fiddle with relevant system settings, and LANG and LC_* variables in the environment if any are set, to help you better understand the issue.

···

--
Robin Dunn
Software Craftsman

Hello Robin.

Do you also get it with nothing but a “import wx”?

Yes, i’ve added a small app, which will reproduce the error. If i add l=wx.Locale(wx.LANGUAGE_GERMAN) in App.OnInit, i get no error.

you may also want to fiddle with relevant system settings, and LANG and
LC_* variables in the environment if any are set, to help you better
understand the issue.

My system settings are all set to german. With LANG and LC_* variables do you mean system environment variables? My system doesn’t have them. Or are these python variables?

Test_dp.py (1.06 KB)