Kaydet (Commit) 03d1b181 authored tarafından Marc-André Lemburg's avatar Marc-André Lemburg

Enable PyOS_snprintf() et al. during alpha phase of 2.2.0 and

add another use case to the socketmodule.
üst 77707673
...@@ -115,6 +115,13 @@ extern DL_IMPORT(PyObject *) PyErr_ProgramText(char *, int); ...@@ -115,6 +115,13 @@ extern DL_IMPORT(PyObject *) PyErr_ProgramText(char *, int);
# define snprintf _snprintf # define snprintf _snprintf
# define vsnprintf _vsnprintf # define vsnprintf _vsnprintf
#endif #endif
/* Always enable the fallback solution during the 2.2.0 alpha cycle
for enhanced testing */
#if PY_VERSION_HEX < 0x020200B0
# undef HAVE_SNPRINTF
#endif
#ifndef HAVE_SNPRINTF #ifndef HAVE_SNPRINTF
#include <stdarg.h> #include <stdarg.h>
extern DL_IMPORT(int) PyOS_snprintf(char *str, size_t size, const char *format, ...); extern DL_IMPORT(int) PyOS_snprintf(char *str, size_t size, const char *format, ...);
......
...@@ -2349,11 +2349,7 @@ PySocket_getaddrinfo(PyObject *self, PyObject *args) ...@@ -2349,11 +2349,7 @@ PySocket_getaddrinfo(PyObject *self, PyObject *args)
return NULL; return NULL;
} }
if (PyInt_Check(pobj)) { if (PyInt_Check(pobj)) {
#ifndef HAVE_SNPRINTF PyOS_snprintf(pbuf, sizeof(pbuf), "%ld", PyInt_AsLong(pobj));
sprintf(pbuf, "%ld", PyInt_AsLong(pobj));
#else
snprintf(pbuf, sizeof(pbuf), "%ld", PyInt_AsLong(pobj));
#endif
pptr = pbuf; pptr = pbuf;
} else if (PyString_Check(pobj)) { } else if (PyString_Check(pobj)) {
pptr = PyString_AsString(pobj); pptr = PyString_AsString(pobj);
...@@ -2424,11 +2420,7 @@ PySocket_getnameinfo(PyObject *self, PyObject *args) ...@@ -2424,11 +2420,7 @@ PySocket_getnameinfo(PyObject *self, PyObject *args)
n = PyArg_ParseTuple(sa, "si|ii", &hostp, &port, &flowinfo, scope_id); n = PyArg_ParseTuple(sa, "si|ii", &hostp, &port, &flowinfo, scope_id);
if (n == 0) if (n == 0)
goto fail; goto fail;
#ifdef HAVE_SNPRINTF PyOS_snprintf(pbuf, sizeof(pbuf), "%d", port);
snprintf(pbuf, sizeof(pbuf), "%d", port);
#else
sprintf(pbuf, "%d", port);
#endif
memset(&hints, 0, sizeof(hints)); memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC; hints.ai_family = PF_UNSPEC;
error = getaddrinfo(hostp, pbuf, &hints, &res); error = getaddrinfo(hostp, pbuf, &hints, &res);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment