[Numpy-discussion] stderr
Pauli Virtanen
pav at iki.fi
Sat Jun 27 15:12:33 EDT 2009
On 2009-06-27, Charles R Harris <charlesr.harris at gmail.com> wrote:
[clip]
>
> PyOS_snprintf(format, sizeof(format), _FMT1, prec);
> res = NumPyOS_ascii_format at type@(buf, buflen, format, val, 0);
> if (res == NULL) {
> fprintf(stderr, "Error while formatting\n");
> return;
> }
>
[clip]
> Do we want to raise an error here? Alternatively, we could use an assert.
I'd advise against asserts. They should be used only for
conditions that are (expected to be) logically impossible. This
one here seems to be possible when out-of-memory, or some other
condition.
Also, an assert makes the program crash on C-level, which is
clearly undesirable in a Python program as it cannot be handled.
Raising an error here seems to be the proper thing to do.
--
Pauli Virtanen
More information about the NumPy-Discussion
mailing list