Skip to content

Commit 8c62518

Browse files
authored
Finally fixing that pesky comma (#212)
1 parent 0e5b857 commit 8c62518

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

include/boost/histogram/python/kwargs.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ T optional_arg(py::kwargs &kwargs, const char *name, T original_value) {
3939
/// Run this last; it will provide an error if other keyword are still present
4040
inline void finalize_args(const py::kwargs &kwargs) {
4141
if(kwargs.size() > 0) {
42-
std::stringstream out;
43-
for(const auto &item : kwargs) {
44-
out << ", " << item.first;
45-
}
46-
throw py::key_error("Unidentfied keywords found:" + out.str());
42+
auto keys = py::str(", ").attr("join")(kwargs.attr("keys")());
43+
throw py::key_error(py::str("Unidentified keywords found: {0}").format(keys));
4744
}
4845
}

tests/test_public_hist.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ def test_fill_int_1d():
6666
h.fill()
6767
with pytest.raises(ValueError):
6868
h.fill(1, 2)
69+
with pytest.raises(KeyError) as k:
70+
h.fill(1, fiddlesticks=2)
71+
assert k.value.args[0] == "Unidentified keywords found: fiddlesticks"
6972

7073
h.fill(-3)
7174
assert h.empty()

0 commit comments

Comments
 (0)