Hi Bram,

It recently came up[0] that the way Vim builds its Python support makes
it fragile to changes in which modules are builtin to the Python
library.

When the set of modules that are builtin/extensions differs from what
Vim knew when it was built, it will at best complain that it can't load
the library.  At worst, it will crash due to undefined symbols.

This is due to Vim compiling in the config.c from the Python install
that existed when it was built.  Removing that, as the attached patch
does, resolves the issue.

I've tested this with both --enable-pythoninterp and
--enable-pythoninterp=dynamic.

[0]: http://bugs.debian.org/681599
-- 
James
GPG Key: 4096R/331BA3DB 2011-12-05 James McCoy <[email protected]>
diff --git a/src/Makefile b/src/Makefile
--- a/src/Makefile
+++ b/src/Makefile
@@ -2559,19 +2559,11 @@
 objects/if_perlsfio.o: if_perlsfio.c
 	$(CCC) $(PERL_CFLAGS) -o $@ if_perlsfio.c
 
-objects/py_config.o: $(PYTHON_CONFDIR)/config.c
-	$(CCC) $(PYTHON_CFLAGS) -o $@ $(PYTHON_CONFDIR)/config.c \
-		-I$(PYTHON_CONFDIR) -DHAVE_CONFIG_H -DNO_MAIN
-
 objects/py_getpath.o: $(PYTHON_CONFDIR)/getpath.c
 	$(CCC) $(PYTHON_CFLAGS) -o $@ $(PYTHON_CONFDIR)/getpath.c \
 		-I$(PYTHON_CONFDIR) -DHAVE_CONFIG_H -DNO_MAIN \
 		$(PYTHON_GETPATH_CFLAGS)
 
-objects/py3_config.o: $(PYTHON3_CONFDIR)/config.c
-	$(CCC) $(PYTHON3_CFLAGS) -o $@ $(PYTHON3_CONFDIR)/config.c \
-		-I$(PYTHON3_CONFDIR) -DHAVE_CONFIG_H -DNO_MAIN
-
 objects/if_python.o: if_python.c if_py_both.h
 	$(CCC) $(PYTHON_CFLAGS) $(PYTHON_CFLAGS_EXTRA) -o $@ if_python.c
 
diff --git a/src/auto/configure b/src/auto/configure
--- a/src/auto/configure
+++ b/src/auto/configure
@@ -5357,11 +5357,7 @@
 	  PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\""
 	fi
 	PYTHON_SRC="if_python.c"
-		if test "x$MACOSX" = "xyes"; then
-	  PYTHON_OBJ="objects/if_python.o"
-	else
-	  PYTHON_OBJ="objects/if_python.o objects/py_config.o"
-	fi
+	PYTHON_OBJ="objects/if_python.o"
 	if test "${vi_cv_var_python_version}" = "1.4"; then
 	   PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
 	fi
@@ -5656,11 +5652,7 @@
         PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\""
       fi
       PYTHON3_SRC="if_python3.c"
-            if test "x$MACOSX" = "xyes"; then
-        PYTHON3_OBJ="objects/if_python3.o"
-      else
-        PYTHON3_OBJ="objects/if_python3.o objects/py3_config.o"
-      fi
+      PYTHON3_OBJ="objects/if_python3.o"
 
                                                 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if -pthread should be used" >&5
 $as_echo_n "checking if -pthread should be used... " >&6; }
diff --git a/src/configure.in b/src/configure.in
--- a/src/configure.in
+++ b/src/configure.in
@@ -916,12 +916,7 @@
 	  PYTHON_CFLAGS="-I${vi_cv_path_python_pfx}/include/python${vi_cv_var_python_version} -I${vi_cv_path_python_epfx}/include/python${vi_cv_var_python_version} -DPYTHON_HOME=\\\"${vi_cv_path_python_pfx}\\\""
 	fi
 	PYTHON_SRC="if_python.c"
-	dnl For Mac OSX 10.2 config.o is included in the Python library.
-	if test "x$MACOSX" = "xyes"; then
-	  PYTHON_OBJ="objects/if_python.o"
-	else
-	  PYTHON_OBJ="objects/if_python.o objects/py_config.o"
-	fi
+	PYTHON_OBJ="objects/if_python.o"
 	if test "${vi_cv_var_python_version}" = "1.4"; then
 	   PYTHON_OBJ="$PYTHON_OBJ objects/py_getpath.o"
 	fi
@@ -1106,12 +1101,7 @@
         PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -I${vi_cv_path_python3_epfx}/include/python${vi_cv_var_python3_version}${vi_cv_var_python3_abiflags} -DPYTHON3_HOME=L\\\"${vi_cv_path_python3_pfx}\\\""
       fi
       PYTHON3_SRC="if_python3.c"
-      dnl For Mac OSX 10.2 config.o is included in the Python library.
-      if test "x$MACOSX" = "xyes"; then
-        PYTHON3_OBJ="objects/if_python3.o"
-      else
-        PYTHON3_OBJ="objects/if_python3.o objects/py3_config.o"
-      fi
+      PYTHON3_OBJ="objects/if_python3.o"
 
       dnl On FreeBSD linking with "-pthread" is required to use threads.
       dnl _THREAD_SAFE must be used for compiling then.

Attachment: signature.asc
Description: Digital signature

Raspunde prin e-mail lui