From 16d43948456ee3c96a2c0b8bd9f446fc85a728b2 Mon Sep 17 00:00:00 2001 From: Andreas Bergmeier Date: Tue, 24 May 2016 09:19:35 +0200 Subject: [PATCH 1/2] Increase available information on invocation error. --- include/pybind11/pybind11.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index ee76a670..02d81e6f 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -422,6 +422,14 @@ protected: msg += it2->signature; msg += "\n"; } + msg += " Invoked with: "; + tuple args_(args, true); + for( std::size_t ti = 0; ti != args_.size(); ++ti) + { + msg += static_cast(static_cast(args_[ti]).str()); + if ((ti + 1) != args_.size() ) + msg += ", "; + } PyErr_SetString(PyExc_TypeError, msg.c_str()); return nullptr; } else if (!result) { From 2dd215711aca9428acb6e1512afd49baeee14b96 Mon Sep 17 00:00:00 2001 From: Andreas Bergmeier Date: Tue, 24 May 2016 10:15:43 +0200 Subject: [PATCH 2/2] Fixed expected test examples for more verbose error output. --- example/example11.ref | 2 +- example/example14.ref | 2 +- example/example5.ref | 2 +- example/issues.ref | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/example/example11.ref b/example/example11.ref index 4c433b75..f4c23aec 100644 --- a/example/example11.ref +++ b/example/example11.ref @@ -29,7 +29,7 @@ kw_func(x=5, y=10) kw_func(x=5, y=10) Caught expected exception: Incompatible function arguments. The following argument types are supported: 1. (x : int = 100L, y : int = 200L) -> NoneType - + Invoked with: kw_func4: 13 17 kw_func4: 1 2 3 kw_func(x=1234, y=5678) diff --git a/example/example14.ref b/example/example14.ref index c18c7ad2..44e68209 100644 --- a/example/example14.ref +++ b/example/example14.ref @@ -11,7 +11,7 @@ Got void ptr : 0x7f9ba0f3c430 Called Example1 destructor (0) Caught expected exception: Incompatible function arguments. The following argument types are supported: 1. (capsule) -> NoneType - + Invoked with: [1, 2, 3] None Got null str : 0x0 diff --git a/example/example5.ref b/example/example5.ref index bfc3cb26..a9c7d465 100644 --- a/example/example5.ref +++ b/example/example5.ref @@ -14,7 +14,7 @@ Polly is a parrot Molly is a dog The following error is expected: Incompatible function arguments. The following argument types are supported: 1. (example.Dog) -> NoneType - + Invoked with: Callback function 1 called! False Callback function 2 called : Hello, x, True, 5 diff --git a/example/issues.ref b/example/issues.ref index af61939c..0bfaca04 100644 --- a/example/issues.ref +++ b/example/issues.ref @@ -7,8 +7,8 @@ Yay.. 0==0, 1==1, 2==2, 3==3, 4==4, 5==5, 6==6, 7==7, 8==8, 9==9, Failed as expected: Incompatible function arguments. The following argument types are supported: 1. (example.issues.ElementA) -> NoneType - + Invoked with: None Failed as expected: Incompatible function arguments. The following argument types are supported: 1. (int) -> int - + Invoked with: 5.2 12.0