@@ -95,12 +95,17 @@ toml::table py_dict_to_toml_table(const py::dict &object) {
95
95
for (auto &&it : object) {
96
96
auto key = it.first ;
97
97
auto value = it.second ;
98
+
98
99
if (!py::isinstance<py::str>(key))
99
100
throw py::type_error (" key must be a string..." );
100
101
101
102
std::string key_string = std::string (py::str (key));
102
103
bool insert_ok = true ;
103
- if (py::isinstance<py::int_>(value)) {
104
+ if (py::isinstance<py::bool_>(value)) {
105
+ bool bool_value = value.cast <py::bool_>();
106
+ auto insert = t.insert_or_assign (key_string, bool_value);
107
+ insert_ok = insert.second ;
108
+ } else if (py::isinstance<py::int_>(value)) {
104
109
int64_t int_value = value.cast <py::int_>();
105
110
auto insert = t.insert_or_assign (key_string, int_value);
106
111
insert_ok = insert.second ;
@@ -112,10 +117,6 @@ toml::table py_dict_to_toml_table(const py::dict &object) {
112
117
std::string string_value = value.cast <py::str>();
113
118
auto insert = t.insert_or_assign (key_string, string_value);
114
119
insert_ok = insert.second ;
115
- } else if (py::isinstance<py::bool_>(value)) {
116
- bool bool_value = value.cast <py::bool_>();
117
- auto insert = t.insert_or_assign (key_string, bool_value);
118
- insert_ok = insert.second ;
119
120
} else if (py::isinstance<py::dict>(value)) {
120
121
toml::table table_value = py_dict_to_toml_table (value.cast <py::dict>());
121
122
auto insert = t.insert_or_assign (key_string, std::move (table_value));
0 commit comments