diff --git a/cpp/src/arrow/python/deserialize.cc b/cpp/src/arrow/python/deserialize.cc index f13070a5883..979399646ad 100644 --- a/cpp/src/arrow/python/deserialize.cc +++ b/cpp/src/arrow/python/deserialize.cc @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -195,8 +196,10 @@ std::vector GetPythonTypes(const UnionArray& data) { std::vector result; auto type = data.type(); for (int i = 0; i < type->num_children(); ++i) { - // stoi is locale dependent, but should be ok for small integers - result.push_back(static_cast(std::stoi(type->child(i)->name()))); + std::istringstream convert(type->child(i)->name()); + int tag; + convert >> tag; + result.push_back(static_cast(tag)); } return result; } diff --git a/cpp/src/arrow/python/serialize.cc b/cpp/src/arrow/python/serialize.cc index 3ccdfc8eee5..4d5b02984cf 100644 --- a/cpp/src/arrow/python/serialize.cc +++ b/cpp/src/arrow/python/serialize.cc @@ -90,8 +90,9 @@ class SequenceBuilder { MakeBuilderFn make_builder) { if (!*child_builder) { child_builder->reset(make_builder()); - // std::to_string is locale dependent, but should be ok for small integers - type_map_[tag] = builder_->AppendChild(*child_builder, std::to_string(tag)); + std::ostringstream convert; + convert << static_cast(tag); + type_map_[tag] = builder_->AppendChild(*child_builder, convert.str()); } return Update(child_builder->get(), type_map_[tag]); }