Opened 13 years ago

#3653 new Bugs

converter collisions behave differently debug|release

Reported by: troy d. straszheim Owned by: Dave Abrahams
Milestone: Boost 1.42.0 Component: python USE GITHUB
Version: Boost 1.41.0 Severity: Problem
Keywords: Cc:

Description

from a thread on the c++-sig list titled "dynamic compile and to-Python converter..."

The 'worst' and most common scenario is, precisely put: more than one python extension module over which we have no control has wrapped type T. We need to use them simultaneously. For instance, here are two modules that both wrap vector<double>. With assertions enabled, this happens:

import converter_collisions1_ext import converter_collisions2_ext

python: /home/troy/Projects/boost/src/libs/python/src/converter/registry.cpp:212: void boost::python::converter::registry::insert(PyObject* (*)(const void*), boost::python::type_info, const PyTypeObject* (*)()): Assertion `slot->m_to_python == 0' failed. zsh: abort python

delightfully, without assertions there is only a warning:

import converter_collisions1_ext import converter_collisions2_ext

main__:1: RuntimeWarning: to-Python converter for std::vector<double, std::allocator<double> > already registered; second conversion method ignored.

So one resolution is to remove the 'assert' that triggers this crash and leave the semantics as-is: second and later converter registrations are warned about and ignored. I'm simply suggesting we give the user more control over this behavior, because in a number of situations (it is up to the user to determine what they are) such control would be useful.

Change History (0)

Note: See TracTickets for help on using tickets.