diff --git a/include/pybind11/eval.h b/include/pybind11/eval.h index a588729182..ee24fd3584 100644 --- a/include/pybind11/eval.h +++ b/include/pybind11/eval.h @@ -52,9 +52,8 @@ object eval(const str &expr, object global = globals(), object local = object()) detail::ensure_builtins_in_globals(global); - /* PyRun_String does not accept a PyObject / encoding specifier, - this seems to be the only alternative */ - std::string buffer = "# -*- coding: utf-8 -*-\n" + (std::string) expr; + // PyRun_String requires a plain C string; Python 3 always assumes UTF-8 source. + std::string buffer = (std::string) expr; int start = 0; switch (mode) {