Hi James, *, 

To work around a bug in python-gnome for the Debian package I applied the
attached patch. You might want to include that in your version or write
a real fix (this is more like a work around).

Problem is, that python can't handle locales very well. From the Debian
report: 

--- cut here -----
Maths behave strangely after importing * from gtk :

>>> from math import sqrt, exp
>>> 4*exp(-.5)/sqrt(2.0)
1.71552776992
>>> from gtk import *
>>> 4*exp(-.5)/sqrt(2.0)
2,82842712475
---------------

This was tracked down to the locale initialization in gtk_init. For more 
information have a look at
http://cgi.debian.org/cgi-bin/bugreport.cgi?archive=yes&bug=59713

Patch is attached.

Thanks

    Torsten

-- 
Torsten Landschoff           Bluehorn@IRC               <[EMAIL PROTECTED]>
           Debian Developer and Quality Assurance Committee Member
--- python-gnome-1.0.52.orig/pygtk/gtkmodule.c
+++ python-gnome-1.0.52/pygtk/gtkmodule.c
@@ -25,6 +25,7 @@
 #endif
 
 #include <gtk/gtk.h>
+#include <locale.h>
 
 #define WITH_XSTUFF
 #ifdef WITH_XSTUFF
@@ -3697,6 +3698,19 @@
     return Py_None;
 }
 
+/* wrap gtk_set_locale because Python does not handle LC_NUMERIC set to 
+ * something different from "C". */
+static PyObject *_wrap_gtk_set_locale(PyObject *self, PyObject *args )
+{
+    char *locale;
+
+    if (!PyArg_ParseTuple(args, ":gtk_set_locale"))
+        return NULL;
+    locale = gtk_set_locale();
+    setlocale(LC_NUMERIC, "C");
+    return PyString_FromString(locale);
+}
+
 static PyObject *_wrap_gtk_main(PyObject *self, PyObject *args) {
     if (!PyArg_ParseTuple(args, ":gtk_main"))
         return NULL;
@@ -6397,6 +6411,7 @@
     { "gtk_signal_handler_unblock_by_data", _wrap_gtk_signal_handler_unblock_by_data, 
1 },
     { "gtk_signal_emitv_by_name", _wrap_gtk_signal_emitv_by_name, 1 },
     { "gtk_init", _wrap_gtk_init, 1 },
+    { "gtk_set_locale", _wrap_gtk_set_locale, 1 }, 
     { "gtk_main", _wrap_gtk_main, 1 },
     { "gtk_main_iteration", _wrap_gtk_main_iteration, 1 },
     { "gtk_events_pending", _wrap_gtk_events_pending, 1 },

Reply via email to