[pkg-boost-devel] Bug#595786: libboost-python-dev: Boost Python should also be compiled against Python3

Steve M. Robbins steve at sumost.ca
Thu Nov 4 01:21:47 UTC 2010


On Tue, Sep 14, 2010 at 01:40:44AM -0400, Andreas Kloeckner wrote:

> I've attached a patch for the build failure. It compiles, but is
> otherwise untested. Would you mind forwarding this to the boost guys for
> review?

I did forward it as a trac ticket: https://svn.boost.org/trac/boost/ticket/4657
and just received a response asking:

    What are the license conditions for the part inserted as " Code
    stolen from py3k/Modules/python.c."?


Andreas, can you address that on the trac ticket, please? 

Thanks,
-Steve

P.S.  The code in question follows.


> +#if PY_MAJOR_VERSION >= 3
> +    // Code stolen from py3k/Modules/python.c.
> +
> +    wchar_t **argv_copy = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*mpi_argc);
> +    /* We need a second copies, as Python might modify the first one. */
> +    wchar_t **argv_copy2 = (wchar_t **)PyMem_Malloc(sizeof(wchar_t*)*mpi_argc);
> +
> +    if (!argv_copy || !argv_copy2) {
> +      fprintf(stderr, "out of memory\n");
> +      return false;
> +    }
> +
> +    std::locale mylocale;
> +    mbstate_t mystate;
> +
> +    const std::codecvt<char, wchar_t, mbstate_t>& myfacet =
> +      std::use_facet<std::codecvt<char, wchar_t, mbstate_t> >(mylocale);
> +
> +    for (int i = 0; i < mpi_argc; i++) 
> +    {
> +      size_t length = strlen(mpi_argv[i]);
> +
> +      wchar_t *dest = (wchar_t *) PyMem_Malloc(sizeof(wchar_t) * (length + 1));
> +
> +      const char *from_next;
> +      wchar_t *to_next;
> +
> +      std::codecvt<wchar_t,char,mbstate_t>::result myresult = 
> +        myfacet.out(mystate,
> +            mpi_argv[i], mpi_argv[i] + length + 1, from_next,
> +            dest, dest+length+1, to_next);
> +
> +      if (myresult != std::codecvt<wchar_t,char,mbstate_t>::ok )
> +      {
> +        fprintf(stderr, "failure translating argv\n");
> +        return 1;
> +      }
> +
> +      argv_copy2[i] = argv_copy[i] = dest;
> +      if (!argv_copy[i])
> +          return false;
> +    }
> +
> +    PySys_SetArgv(mpi_argc, argv_copy);
> +
> +    for (int i = 0; i < mpi_argc; i++) {
> +        PyMem_Free(argv_copy2[i]);
> +    }
> +    PyMem_Free(argv_copy);
> +    PyMem_Free(argv_copy2);
> +#else
>      PySys_SetArgv(mpi_argc, mpi_argv);
> +#endif

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-boost-devel/attachments/20101103/24b8cd2d/attachment.pgp>


More information about the pkg-boost-devel mailing list