]> granicus.if.org Git - python/commitdiff
Enable PyOS_snprintf() et al. during alpha phase of 2.2.0 and
authorMarc-André Lemburg <mal@egenix.com>
Tue, 31 Jul 2001 18:05:33 +0000 (18:05 +0000)
committerMarc-André Lemburg <mal@egenix.com>
Tue, 31 Jul 2001 18:05:33 +0000 (18:05 +0000)
add another use case to the socketmodule.

Include/pyerrors.h
Modules/socketmodule.c

index 3b2bfbcbb9a72562839564f43011d846ac8d82e7..1ee4fe2fab0572cdadead1bf94e89c0ead5cdd4e 100644 (file)
@@ -115,6 +115,13 @@ extern DL_IMPORT(PyObject *) PyErr_ProgramText(char *, int);
 # define snprintf _snprintf
 # define vsnprintf _vsnprintf
 #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
 #include <stdarg.h>
 extern DL_IMPORT(int) PyOS_snprintf(char *str, size_t size, const char  *format, ...);
index 16b08526346f3b29d97e17d1a4a0ce5dade5f595..706ca78bcd7f81c992700dcee6f7b1512d3e8e99 100644 (file)
@@ -2349,11 +2349,7 @@ PySocket_getaddrinfo(PyObject *self, PyObject *args)
                return NULL;
        }
        if (PyInt_Check(pobj)) {
-#ifndef HAVE_SNPRINTF
-               sprintf(pbuf, "%ld", PyInt_AsLong(pobj));
-#else
-               snprintf(pbuf, sizeof(pbuf), "%ld", PyInt_AsLong(pobj));
-#endif
+               PyOS_snprintf(pbuf, sizeof(pbuf), "%ld", PyInt_AsLong(pobj));
                pptr = pbuf;
        } else if (PyString_Check(pobj)) {
                pptr = PyString_AsString(pobj);
@@ -2424,11 +2420,7 @@ PySocket_getnameinfo(PyObject *self, PyObject *args)
        n = PyArg_ParseTuple(sa, "si|ii", &hostp, &port, &flowinfo, scope_id);
        if (n == 0)
                goto fail;
-#ifdef HAVE_SNPRINTF
-       snprintf(pbuf, sizeof(pbuf), "%d", port);
-#else
-       sprintf(pbuf, "%d", port);
-#endif
+       PyOS_snprintf(pbuf, sizeof(pbuf), "%d", port);
        memset(&hints, 0, sizeof(hints));
        hints.ai_family = PF_UNSPEC;
        error = getaddrinfo(hostp, pbuf, &hints, &res);