Skip to content

Commit 8b97caa

Browse files
committed
Warn about duplicate to-python converters and show the name of the
offending type. [SVN r20023]
1 parent 3b74aab commit 8b97caa

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

doc/news.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ <h2 align="center">News/Change Log</h2>
2929
<hr>
3030

3131
<dl class="page-index">
32+
<dt>11 Sept 2003</dt>
33+
34+
<dd>Changed the response to multiple to-python converters being
35+
registered for the same type from a hard error into warning;
36+
Boost.Python now reports the offending type in the message.
37+
3238
<dt>9 Sept 2003</dt>
3339

3440
<dd>Added new <code><a
@@ -164,7 +170,7 @@ <h2 align="center">News/Change Log</h2>
164170

165171
<p>Revised
166172
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
167-
1 August 2003 <!--webbot bot="Timestamp" endspan i-checksum="39359" -->
173+
11 September 2003 <!--webbot bot="Timestamp" endspan i-checksum="39359" -->
168174
</p>
169175

170176
<p><i>&copy; Copyright <a href="../../../people/dave_abrahams.htm">Dave

src/converter/registry.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <set>
1111
#include <stdexcept>
12+
#include <boost/lexical_cast.hpp>
1213

1314
#if defined(__APPLE__) && defined(__MACH__) && defined(__GNUC__) \
1415
&& __GNUC__ == 3 && __GNUC_MINOR__ == 3 && !defined(__APPLE_CC__)
@@ -161,8 +162,16 @@ namespace registry
161162
assert(slot == 0); // we have a problem otherwise
162163
if (slot != 0)
163164
{
164-
throw std::runtime_error(
165-
"trying to register to_python_converter for a type which already has a registered to_python_converter");
165+
std::string msg(
166+
"to-Python converter for "
167+
+ lexical_cast<std::string>(source_t)
168+
+ " already registered; second conversion method ignored."
169+
);
170+
171+
if ( ::PyErr_Warn( NULL, const_cast<char*>(msg.c_str()) ) )
172+
{
173+
throw_error_already_set();
174+
}
166175
}
167176
slot = f;
168177
}

0 commit comments

Comments
 (0)