Skip to content

Commit 1ede69e

Browse files
committed
Try to fix const issue and allocate vector properly
1 parent 52d88c3 commit 1ede69e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

include/pybind11/embed.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ inline void set_interpreter_argv(int argc, const char* const* argv, bool add_pro
130130
// SetArgv* on python 3 takes wchar_t, so we have to convert.
131131
std::unique_ptr<wchar_t*[]> widened_argv(new wchar_t*[argv_size]);
132132
std::vector< std::unique_ptr<wchar_t[], wide_char_arg_deleter> > widened_argv_entries;
133+
widened_argv_entries.reserve(argv_size);
133134
for (size_t ii = 0; ii < argv_size; ++ii) {
134135
widened_argv_entries.emplace_back(widen_chars(safe_argv[ii]));
135136
if (!widened_argv_entries.back()) {
@@ -143,7 +144,7 @@ inline void set_interpreter_argv(int argc, const char* const* argv, bool add_pro
143144
auto pysys_argv = widened_argv.get();
144145
#else
145146
// python 2.x
146-
auto pysys_argv = safe_argv;
147+
char** pysys_argv = const_cast<char**>safe_argv;
147148
#endif
148149

149150
PySys_SetArgvEx(argc, pysys_argv, static_cast<int>(add_program_dir_to_path));

0 commit comments

Comments
 (0)