James Vega wrote:

> >>> On Thu, Jul 22, 2010 at 12:36:27AM -0700, Nico Raffo wrote:
> >>> > If Vim is compiled with both --enable-pythoninterp and --enable-
> >>> > python3interp, errors occur when importing many python modules. To
> >>> > reproduce, compile as described then try something like:
> >>> >
> >>> > :py import termios
> >>> > or
> >>> > :py3 import termios
> >>> >
> >>> > Which gives the error:
> >>> >
> >>> > ImportError: /usr/lib/python3.1/lib-dynload/termios.so: undefined
> >>> > symbol: PyExc_TypeError
> >>> >
> >>> > This doesn't happen with all modules. Mostly just those with odd .so
> >>> > files.
> >>>
> >>> I had been meaning to check whether something like that would happen
> >>> with the Python interfaces. =A0I saw something similar when testing the
> >>> Perl interface. =A0Does the attached patch fix it?
> >>
> >> Thanks, I'll include it. =A0It fixes the problem on my system.
> >
> > The attached patch corrects how DYNAMIC_PYTHON_DLL is specified so that
> > it correctly includes the SONAME (libpython2.6.so.1 instead of
> > libpython2.6.so). =A0The former is always available while the latter is
> > typically only available when the relevant -dev package is installed.
> >
> > I'm looking into the crash that was reported as well, but I'm not sure
> > if that can be avoided as long as both interpreters are getting loaded.
> > At a quick glance, it seems like if_python may not be handling locking
> > properly. =A0I'll dig into this some more later tonight.
> 
> Because we have to use RTLD_GLOBAL (since the C extensions aren't linked
> against libpython), it's not safe to use both the Python 2 & 3
> interfaces in the same session of Vim.  It looks like the options are
> either:
> 
> 1) Only allow one interface to be enabled at a time.
> 2) Keep track of whether one of the Python interfaces has been
>    initialized and error out if the other one tries to be initialized.
> 
> I'd personally prefer the latter since that still allows one to build a
> single Vim binary that supports both Python 2 & 3, but only one of the
> interfaces can be used per Vim session.

The problem is that then the first :python or :py3 command blocks the
others.  But crashing is worse, thus we should do this at least.

Would it be possible to unload the other Python version?  Thus when
using ":python" after ":py3" it would unload Python 3 and load Python 2.
Would that work?

I did a quick try by calling python_end() when Python 3 is loaded, and
calling python3_end() when Python is loaded, but switching back and
forth causes a SEGV:

#0  0x00fe0a20 in ?? ()
#1  0x0820e059 in Python_RestoreThread () at if_python.c:472
#2  0x0820e1e2 in DoPythonCommand (eap=0xbfffee8c, 
    cmd=0x83d5403 "print \"hello\"") at if_python.c:634
#3  0x0820e269 in ex_python (eap=0xbfffee8c) at if_python.c:673

Apparently the _end() functions don't cleaup properly.

-- 
SIGFUN -- signature too funny (core dumped)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui