[Numpy-svn] r5399 - trunk/numpy/core/src

numpy-svn@scip... numpy-svn@scip...
Sat Jul 12 18:49:13 CDT 2008


Author: charris
Date: 2008-07-12 18:49:10 -0500 (Sat, 12 Jul 2008)
New Revision: 5399

Modified:
   trunk/numpy/core/src/arrayobject.c
   trunk/numpy/core/src/ufuncobject.c
Log:
Replace snprintf with PyOS_snprintf.
There remain four occurrences of sprintf that should be replaced.


Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c	2008-07-12 22:01:20 UTC (rev 5398)
+++ trunk/numpy/core/src/arrayobject.c	2008-07-12 23:49:10 UTC (rev 5399)
@@ -4343,9 +4343,9 @@
     if (repr) {
         if (PyArray_ISEXTENDED(self)) {
             char buf[100];
-            snprintf(buf, sizeof(buf), "%d", self->descr->elsize);
+            PyOS_snprintf(buf, sizeof(buf), "%d", self->descr->elsize);
             sprintf(string+n, ", '%c%s')", self->descr->type, buf);
-            ret = PyString_FromStringAndSize(string, n+6+strlen(buf));
+            ret = PyString_FromStringAndSize(string, n + 6 + strlen(buf));
         }
         else {
             sprintf(string+n, ", '%c')", self->descr->type);
@@ -4360,8 +4360,8 @@
     return ret;
 }
 
-static PyObject *PyArray_StrFunction=NULL;
-static PyObject *PyArray_ReprFunction=NULL;
+static PyObject *PyArray_StrFunction = NULL;
+static PyObject *PyArray_ReprFunction = NULL;
 
 /*NUMPY_API
   Set the array print function to be a Python function.
@@ -7358,8 +7358,8 @@
         if (PyCObject_Check(ip)) {
             inter=(PyArrayInterface *)PyCObject_AsVoidPtr(ip);
             if (inter->two == 2) {
-                snprintf(buf, 40, "|%c%d", inter->typekind,
-                         inter->itemsize);
+                PyOS_snprintf(buf, sizeof(buf),
+                        "|%c%d", inter->typekind, inter->itemsize);
                 chktype = _array_typedescr_fromstr(buf);
             }
         }
@@ -8539,7 +8539,8 @@
     }
 
     if (thetype == NULL) {
-        snprintf(buf, 40, "%c%c%d", endian, inter->typekind, inter->itemsize);
+        PyOS_snprintf(buf, sizeof(buf),
+                "%c%c%d", endian, inter->typekind, inter->itemsize);
         if (!(thetype=_array_typedescr_fromstr(buf))) {
             Py_DECREF(attr);
             return NULL;

Modified: trunk/numpy/core/src/ufuncobject.c
===================================================================
--- trunk/numpy/core/src/ufuncobject.c	2008-07-12 22:01:20 UTC (rev 5398)
+++ trunk/numpy/core/src/ufuncobject.c	2008-07-12 23:49:10 UTC (rev 5399)
@@ -670,7 +670,8 @@
 
         switch(method) {
         case UFUNC_ERR_WARN:
-            snprintf(msg, 100, "%s encountered in %s", errtype, name);
+            PyOS_snprintf(msg, sizeof(msg),
+                    "%s encountered in %s", errtype, name);
             if (PyErr_Warn(PyExc_RuntimeWarning, msg) < 0) goto fail;
             break;
         case UFUNC_ERR_RAISE:
@@ -714,7 +715,8 @@
                                  errtype, name);
                     goto fail;
                 }
-                snprintf(msg, 100, "Warning: %s encountered in %s\n", errtype, name);
+                PyOS_snprintf(msg, sizeof(msg),
+                        "Warning: %s encountered in %s\n", errtype, name);
                 ret = PyObject_CallMethod(pyfunc, "write", "s", msg);
                 if (ret == NULL) goto fail;
                 Py_DECREF(ret);



More information about the Numpy-svn mailing list