Skip to content

Commit f0ee877

Browse files
committed
Changed "Invoked with" output to use repr() instead of str()
This gives more informative output, often including the type (or at least some hint about the type).
1 parent c4d8196 commit f0ee877

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

include/pybind11/pybind11.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ class cpp_function : public function {
509509
msg += "\nInvoked with: ";
510510
auto args_ = reinterpret_borrow<tuple>(args);
511511
for (size_t ti = overloads->is_constructor ? 1 : 0; ti < args_.size(); ++ti) {
512-
msg += static_cast<std::string>(pybind11::str(args_[ti]));
512+
msg += pybind11::repr(args_[ti]);
513513
if ((ti + 1) != args_.size() )
514514
msg += ", ";
515515
}

tests/test_issues.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_str_issue(msg):
9696
1. m.issues.StrIssue(arg0: int)
9797
2. m.issues.StrIssue()
9898
99-
Invoked with: no, such, constructor
99+
Invoked with: 'no', 'such', 'constructor'
100100
"""
101101

102102

0 commit comments

Comments
 (0)