Commit 4afeed64 authored by Jon Kåre Hellan's avatar Jon Kåre Hellan

Test for BROKEN_PY_INITIALIZE feature (before Python 2.0, Python would

* configure.in: Test for BROKEN_PY_INITIALIZE feature (before
Python 2.0, Python would write to the environment, and we had to
work around it.)

* acconfig.h: Add BROKEN_PY_INITIALIZE

* plugins/python-loader/python-loader.c (BROKEN_PY_INITIALIZE): Test
for this condition is now autoconfiscated.

* plugins/python/python.c (BROKEN_PY_INITIALIZE): Test for this
condition is now autoconfiscated.  struct FuncData: Include category.
(register_function): Save category.
(plugin_can_deactivate_general): Able to deactivate unless a
function is in use.
(plugin_cleanup_general): Do cleanup.
parent 8ab6aeac
2002-07-20 Jon K Hellan <hellan@acm.org>
* configure.in: Test for BROKEN_PY_INITIALIZE feature (before
Python 2.0, Python would write to the environment, and we had to
work around it.)
* acconfig.h: Add BROKEN_PY_INITIALIZE
2002-07-20 Jody Goldberg <jody@gnome.org>
* src/item-grid.c (item_grid_init) : init the cursor timer.
......
2002-07-20 Jon K Hellan <hellan@acm.org>
* configure.in: Test for BROKEN_PY_INITIALIZE feature (before
Python 2.0, Python would write to the environment, and we had to
work around it.)
* acconfig.h: Add BROKEN_PY_INITIALIZE
2002-07-20 Jody Goldberg <jody@gnome.org>
* src/item-grid.c (item_grid_init) : init the cursor timer.
......
2002-07-20 Jon K Hellan <hellan@acm.org>
* configure.in: Test for BROKEN_PY_INITIALIZE feature (before
Python 2.0, Python would write to the environment, and we had to
work around it.)
* acconfig.h: Add BROKEN_PY_INITIALIZE
2002-07-20 Jody Goldberg <jody@gnome.org>
* src/item-grid.c (item_grid_init) : init the cursor timer.
......
......@@ -17,5 +17,6 @@
#undef HAVE_IEEE754_H
#undef WITH_LONG_DOUBLE
#undef MUST_PROTOTYPE_STRTOLD
#undef BROKEN_PY_INITIALIZE
@BOTTOM@
......@@ -445,6 +445,12 @@ if $try_python; then
PY_EXEC_PREFIX=`$python_prog -c 'import sys ; print sys.exec_prefix'`
changequote(<<, >>)dnl
PY_VERSION=`$python_prog -c 'import sys ; print sys.version[0:3]'`
broken_py_initialize=`$python_prog -c \
'import sys
if int(sys.version[0]) < 2:
print "yes"
else:
print "no"'`
changequote([, ])dnl
if test -f $PY_PREFIX/include/python$PY_VERSION/Python.h; then
PY_LIBS="python$PY_VERSION"
......@@ -459,6 +465,9 @@ if $try_python; then
AC_SUBST(PY_LIB_LOC)
AC_SUBST(PY_CFLAGS)
AC_SUBST(PY_EXTRA_LIBS)
if test "x$broken_py_initialize" = "xyes"; then
AC_DEFINE(BROKEN_PY_INITIALIZE)
fi
else
python_val=false
fi
......
2002-07-20 Jon K Hellan <hellan@acm.org>
* python-loader.c (BROKEN_PY_INITIALIZE): Test for this condition
is now autoconfiscated.
2002-06-20 Jon K Hellan <hellan@acm.org>
* python-loader.c: Include pygobject.h if Pygtk is installed.
......
......@@ -31,8 +31,6 @@
#include "module-plugin-defs.h"
#include "py-gnumeric.h"
#define BROKEN_PY_INITIALIZE
GNUMERIC_MODULE_PLUGIN_INFO_DECL;
......@@ -90,11 +88,10 @@ initialize_python_if_needed (void)
#ifdef BROKEN_PY_INITIALIZE
int i;
/* Python's convertenviron has gotten into its head that it can
write to the strings in the environment. We have little choice
but to allocate a copy of everything. */
/* Before Python 2.0, Python's convertenviron would write to
the strings in the environment. We had little choice but
to allocate a copy of everything. */
/* Fixed in Python 2.0. JK */
for (i = 0; environ[i]; i++)
environ[i] = g_strdup (environ[i]);
#endif
......
2002-07-20 Jon K Hellan <hellan@acm.org>
* python.c (BROKEN_PY_INITIALIZE): Test for this condition is now
autoconfiscated.
struct FuncData: Include category.
(register_function): Save category.
(plugin_can_deactivate_general): Able to deactivate unless a
function is in use.
(plugin_cleanup_general): Do cleanup.
2002-05-29 Jody Goldberg <jody@gnome.org>
* Release 1.1.4
......
......@@ -26,8 +26,6 @@
#include "Python.h"
#define BROKEN_PY_INITIALIZE
GNUMERIC_MODULE_PLUGIN_INFO_DECL;
/* Classes we define in Python code, and where we define them. */
......@@ -592,6 +590,7 @@ value_from_python (PyObject *o, EvalPos const *pos)
typedef struct {
FunctionDefinition *fndef;
FunctionCategory *category;
PyObject *codeobj;
} FuncData;
......@@ -851,8 +850,9 @@ register_function (PyObject *m, PyObject *py_args)
marshal_func_nodes);
fdata = g_new (FuncData, 1);
fdata->fndef = fndef;
fdata->codeobj = codeobj;
fdata->fndef = fndef;
fdata->category = cat;
fdata->codeobj = codeobj;
Py_INCREF (codeobj);
funclist = g_list_append (funclist, fdata);
......@@ -897,13 +897,36 @@ initgnumeric (void)
gboolean
plugin_can_deactivate_general (void)
{
return FALSE;
FuncData *fdata;
GList *l;
for (l = funclist; l != NULL; l = l->next) {
fdata = (FuncData *) l->data;
if (func_get_ref_count (fdata->fndef) != 0)
return FALSE;
}
return TRUE;
}
void
plugin_cleanup_general (ErrorInfo **ret_error)
{
FuncData *fdata;
*ret_error = NULL;
while (funclist) {
fdata = (FuncData *) funclist->data;
if (fdata->fndef->help) {
g_free ((char *) (*fdata->fndef->help));
g_free (fdata->fndef->help);
}
fdata->fndef->help = NULL;
function_remove (fdata->category, fdata->fndef->name);
g_free (fdata);
funclist = g_list_delete_link (funclist, funclist);
}
Py_Finalize ();
}
#ifdef BROKEN_PY_INITIALIZE
......@@ -918,9 +941,9 @@ plugin_init_general (ErrorInfo **ret_error)
int i;
/*
* Python's convertenviron has gotten into its head that it can
* write to the strings in the environment. We have little choice
* but to allocate a copy of everything.
* Before Python 2.0, Python's convertenviron would write to the
* strings in the environment. We had little choice but to
* allocate a copy of everything.
*/
for (i = 0; environ[i]; i++)
environ[i] = g_strdup (environ[i]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment