Skip to content

Commit

Permalink
Backport r5399.
Browse files Browse the repository at this point in the history
  • Loading branch information
charris committed Jul 15, 2008
1 parent 681a675 commit c72742e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions numpy/core/src/arrayobject.c
Expand Up @@ -4342,7 +4342,7 @@ array_repr_builtin(PyArrayObject *self, int repr)
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));
}
Expand Down Expand Up @@ -7339,7 +7339,7 @@ _array_find_type(PyObject *op, PyArray_Descr *minitype, int max)
if (PyCObject_Check(ip)) {
inter=(PyArrayInterface *)PyCObject_AsVoidPtr(ip);
if (inter->two == 2) {
snprintf(buf, 40, "|%c%d", inter->typekind,
PyOS_snprintf(buf, 40, "|%c%d", inter->typekind,
inter->itemsize);
chktype = _array_typedescr_fromstr(buf);
}
Expand Down Expand Up @@ -8520,7 +8520,8 @@ PyArray_FromStructInterface(PyObject *input)
}

if (thetype == NULL) {
snprintf(buf, 40, "%c%c%d", endian, inter->typekind, inter->itemsize);
PyOS_snprintf(buf, 40,
"%c%c%d", endian, inter->typekind, inter->itemsize);
if (!(thetype=_array_typedescr_fromstr(buf))) {
Py_DECREF(attr);
return NULL;
Expand Down
6 changes: 4 additions & 2 deletions numpy/core/src/ufuncobject.c
Expand Up @@ -670,7 +670,8 @@ _error_handler(int method, PyObject *errobj, char *errtype, int retstatus, int *

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:
Expand Down Expand Up @@ -714,7 +715,8 @@ _error_handler(int method, PyObject *errobj, char *errtype, int retstatus, int *
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);
Expand Down

0 comments on commit c72742e

Please sign in to comment.