diff --git a/src/_path.cpp b/src/_path.cpp index f8e09baae813..e99636ce06bd 100644 --- a/src/_path.cpp +++ b/src/_path.cpp @@ -1524,8 +1524,10 @@ _path_module::convert_to_svg(const Py::Tuple& args) int precision = Py::Int(args[4]); + #if PY_VERSION_HEX < 0x02070000 char format[64]; snprintf(format, 64, "%s.%dg", "%", precision); + #endif typedef agg::conv_transform transformed_path_t; typedef PathNanRemover nan_removal_t; @@ -1568,9 +1570,23 @@ _path_module::convert_to_svg(const Py::Tuple& args) *p++ = ' '; } - p += snprintf(p, buffersize - (p - buffer), format, x); + #if PY_VERSION_HEX >= 0x02070000 + char* str; + str = PyOS_double_to_string(x, 'g', precision, 0, NULL); + p += snprintf(p, buffersize - (p - buffer), str); + PyMem_Free(str); *p++ = ' '; - p += snprintf(p, buffersize - (p - buffer), format, y); + str = PyOS_double_to_string(y, 'g', precision, 0, NULL); + p += snprintf(p, buffersize - (p - buffer), str); + PyMem_Free(str); + #else + char str[64]; + PyOS_ascii_formatd(str, 64, format, x); + p += snprintf(p, buffersize - (p - buffer), str); + *p++ = ' '; + PyOS_ascii_formatd(str, 64, format, y); + p += snprintf(p, buffersize - (p - buffer), str); + #endif --wait; }