From 8b97caae46ef60091de5bb29681b0fa31439c082 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 11 Sep 2003 15:09:11 +0000 Subject: [PATCH] Warn about duplicate to-python converters and show the name of the offending type. [SVN r20023] --- doc/news.html | 8 +++++++- src/converter/registry.cpp | 13 +++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/doc/news.html b/doc/news.html index 3b38951a..19b00ecb 100644 --- a/doc/news.html +++ b/doc/news.html @@ -29,6 +29,12 @@
+
11 Sept 2003
+ +
Changed the response to multiple to-python converters being + registered for the same type from a hard error into warning; + Boost.Python now reports the offending type in the message. +
9 Sept 2003
Added new Revised - 1 August 2003 + 11 September 2003

© Copyright Dave diff --git a/src/converter/registry.cpp b/src/converter/registry.cpp index 2e747a14..ce12ec81 100644 --- a/src/converter/registry.cpp +++ b/src/converter/registry.cpp @@ -9,6 +9,7 @@ #include #include +#include #if defined(__APPLE__) && defined(__MACH__) && defined(__GNUC__) \ && __GNUC__ == 3 && __GNUC_MINOR__ == 3 && !defined(__APPLE_CC__) @@ -161,8 +162,16 @@ namespace registry assert(slot == 0); // we have a problem otherwise if (slot != 0) { - throw std::runtime_error( - "trying to register to_python_converter for a type which already has a registered to_python_converter"); + std::string msg( + "to-Python converter for " + + lexical_cast(source_t) + + " already registered; second conversion method ignored." + ); + + if ( ::PyErr_Warn( NULL, const_cast(msg.c_str()) ) ) + { + throw_error_already_set(); + } } slot = f; }