]> git.saurik.com Git - wxWidgets.git/commitdiff
Reset LC_NUMERIC to "C" for Python < 2.4. This fixes Python's float parser.
authorRobin Dunn <robin@alldunn.com>
Fri, 12 Nov 2004 18:12:49 +0000 (18:12 +0000)
committerRobin Dunn <robin@alldunn.com>
Fri, 12 Nov 2004 18:12:49 +0000 (18:12 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30503 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/src/_intl.i
wxPython/src/helpers.cpp

index 9f8f54fe62b0947f5d2748164e96cb9bd8b54673..5901e839a58e76377490f092deb2f89b341e6b36 100644 (file)
@@ -16,6 +16,7 @@
 //---------------------------------------------------------------------------
 
 %{
+#include <locale.h>
 %}
 
 //---------------------------------------------------------------------------
@@ -311,24 +312,51 @@ public:
     %extend {
         wxLocale(int language = -1,
                  int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING) {
+            wxLocale* loc;
             if (language == -1)
-                return new wxLocale();
+                loc = new wxLocale();
             else
-                return new wxLocale(language, flags);
+                loc = new wxLocale(language, flags);
+            // Python before 2.4 needs to have LC_NUMERIC set to "C" in order
+            // for the floating point conversions and such to work right.
+%#if PY_VERSION_HEX < 0x02040000
+            setlocale(LC_NUMERIC, "C");
+%#endif
+            return loc;
         }
     }
 
         // restores old locale
     ~wxLocale();
 
-    %name(Init1)bool Init(const wxString& szName,
-                          const wxString& szShort = wxPyEmptyString,
-                          const wxString& szLocale = wxPyEmptyString,
-                          bool bLoadDefault = true,
-                          bool bConvertEncoding = false);
+    %extend { 
+        bool Init1(const wxString& szName,
+                   const wxString& szShort = wxPyEmptyString,
+                   const wxString& szLocale = wxPyEmptyString,
+                   bool bLoadDefault = true,
+                   bool bConvertEncoding = false) {
+            bool rc = self->Init(szName, szShort, szLocale, bLoadDefault, bConvertEncoding);
+            // Python before 2.4 needs to have LC_NUMERIC set to "C" in order
+            // for the floating point conversions and such to work right.
+%#if PY_VERSION_HEX < 0x02040000
+            setlocale(LC_NUMERIC, "C");
+%#endif
+            return rc;
+        }
+
+        bool Init2(int language = wxLANGUAGE_DEFAULT,
+                   int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING) {
+            bool rc = self->Init(language, flags);
+            // Python before 2.4 needs to have LC_NUMERIC set to "C" in order
+            // for the floating point conversions and such to work right.
+%#if PY_VERSION_HEX < 0x02040000
+            setlocale(LC_NUMERIC, "C");
+%#endif
+            return rc;
+        }
+    }
 
-    %name(Init2) bool Init(int language = wxLANGUAGE_DEFAULT,
-                           int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
+    
 
     %pythoncode {
     def Init(self, *_args, **_kwargs):
index ae0ace5dc59b35e7cc4fbd5244508630e1dab85b..c10641926d0f3e387292d30975a5bacac2059c23 100644 (file)
@@ -49,7 +49,7 @@
 
 //----------------------------------------------------------------------
 
-#if PYTHON_API_VERSION <= 1007 && wxUSE_UNICODE
+#if PYTHON_API_VERSION < 1009 && wxUSE_UNICODE
 #error Python must support Unicode to use wxWindows Unicode
 #endif
 
@@ -421,10 +421,10 @@ void wxPyApp::_BootstrapApp()
             goto error;
         }
 
-        // On wxGTK the locale will be changed to match the system settings, but
-        // Python needs to have LC_NUMERIC set to "C" in order for the floating
-        // point conversions and such to work right.
-#if defined(__WXGTK__) && PYTHON_API_VERSION <= 1012
+        // On wxGTK the locale will be changed to match the system settings,
+        // but Python before 2.4 needs to have LC_NUMERIC set to "C" in order
+        // for the floating point conversions and such to work right.
+#if defined(__WXGTK__) && PY_VERSION_HEX < 0x02040000
         setlocale(LC_NUMERIC, "C");
 #endif