Skip to content

Commit 3310574

Browse files
committed
fix KeyError exception in taglist accessor
1 parent 61e994d commit 3310574

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/osm.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@
99
#include "std_pair.hpp"
1010

1111

12-
inline const char *get_tag_by_key(osmium::TagList const& obj, const char *value)
12+
inline const char *get_tag_by_key(osmium::TagList const& obj, const char *key)
1313
{
14-
const char* v = obj.get_value_by_key(value);
15-
if (!v)
14+
if (!key) {
15+
PyErr_SetString(PyExc_KeyError, "Key 'None' not allowed.");
16+
boost::python::throw_error_already_set();
17+
}
18+
19+
const char* v = obj.get_value_by_key(key);
20+
if (!v) {
1621
PyErr_SetString(PyExc_KeyError, "No tag with that key.");
22+
boost::python::throw_error_already_set();
23+
}
1724
return v;
1825
}
1926

0 commit comments

Comments
 (0)