|
51 | 51 | #endif
|
52 | 52 | /**********************************************/
|
53 | 53 |
|
| 54 | +#if NPY_DT_DBG_TRACING |
| 55 | +/* |
| 56 | + * Thin wrapper around print that ignores exceptions |
| 57 | + */ |
| 58 | +static void |
| 59 | +_safe_print(PyObject *obj) |
| 60 | +{ |
| 61 | + if (PyObject_Print(obj, stdout, 0) < 0) { |
| 62 | + PyErr_Clear(); |
| 63 | + printf("<error during print>"); |
| 64 | + } |
| 65 | +} |
| 66 | +#endif |
| 67 | + |
54 | 68 | /*
|
55 | 69 | * Returns a transfer function which DECREFs any references in src_type.
|
56 | 70 | *
|
@@ -1042,9 +1056,9 @@ get_nbo_cast_datetime_transfer_function(int aligned,
|
1042 | 1056 |
|
1043 | 1057 | #if NPY_DT_DBG_TRACING
|
1044 | 1058 | printf("Dtype transfer from ");
|
1045 |
| - PyObject_Print((PyObject *)src_dtype, stdout, 0); |
| 1059 | + _safe_print((PyObject *)src_dtype); |
1046 | 1060 | printf(" to ");
|
1047 |
| - PyObject_Print((PyObject *)dst_dtype, stdout, 0); |
| 1061 | + _safe_print((PyObject *)dst_dtype); |
1048 | 1062 | printf("\n");
|
1049 | 1063 | printf("has conversion fraction %lld/%lld\n", num, denom);
|
1050 | 1064 | #endif
|
@@ -1089,9 +1103,9 @@ get_nbo_datetime_to_string_transfer_function(int aligned,
|
1089 | 1103 |
|
1090 | 1104 | #if NPY_DT_DBG_TRACING
|
1091 | 1105 | printf("Dtype transfer from ");
|
1092 |
| - PyObject_Print((PyObject *)src_dtype, stdout, 0); |
| 1106 | + _safe_print((PyObject *)src_dtype); |
1093 | 1107 | printf(" to ");
|
1094 |
| - PyObject_Print((PyObject *)dst_dtype, stdout, 0); |
| 1108 | + _safe_print((PyObject *)dst_dtype); |
1095 | 1109 | printf("\n");
|
1096 | 1110 | #endif
|
1097 | 1111 |
|
@@ -1211,9 +1225,9 @@ get_nbo_string_to_datetime_transfer_function(int aligned,
|
1211 | 1225 |
|
1212 | 1226 | #if NPY_DT_DBG_TRACING
|
1213 | 1227 | printf("Dtype transfer from ");
|
1214 |
| - PyObject_Print((PyObject *)src_dtype, stdout, 0); |
| 1228 | + _safe_print((PyObject *)src_dtype); |
1215 | 1229 | printf(" to ");
|
1216 |
| - PyObject_Print((PyObject *)dst_dtype, stdout, 0); |
| 1230 | + _safe_print((PyObject *)dst_dtype); |
1217 | 1231 | printf("\n");
|
1218 | 1232 | #endif
|
1219 | 1233 |
|
@@ -3421,9 +3435,13 @@ PyArray_GetDTypeTransferFunction(int aligned,
|
3421 | 3435 |
|
3422 | 3436 | #if NPY_DT_DBG_TRACING
|
3423 | 3437 | printf("Calculating dtype transfer from ");
|
3424 |
| - PyObject_Print((PyObject *)src_dtype, stdout, 0); |
| 3438 | + if (PyObject_Print((PyObject *)src_dtype, stdout, 0) < 0) { |
| 3439 | + return NPY_FAIL; |
| 3440 | + } |
3425 | 3441 | printf(" to ");
|
3426 |
| - PyObject_Print((PyObject *)dst_dtype, stdout, 0); |
| 3442 | + if (PyObject_Print((PyObject *)dst_dtype, stdout, 0) < 0) { |
| 3443 | + return NPY_FAIL; |
| 3444 | + } |
3427 | 3445 | printf("\n");
|
3428 | 3446 | #endif
|
3429 | 3447 |
|
|
0 commit comments