| 
48 | 48 |  */  | 
49 | 49 | NPY_NO_EXPORT npy_intp REQUIRED_STR_LEN[] = {0, 3, 5, 10, 10, 20, 20, 20, 20};  | 
50 | 50 | 
 
  | 
51 |  | -/*  | 
52 |  | - * Whether or not legacy value-based promotion/casting is used.  | 
53 |  | - */  | 
54 |  | - | 
55 |  | -NPY_NO_EXPORT PyObject *NO_NEP50_WARNING_CTX = NULL;  | 
56 |  | -NPY_NO_EXPORT PyObject *npy_DTypePromotionError = NULL;  | 
57 |  | -NPY_NO_EXPORT PyObject *npy_UFuncNoLoopError = NULL;  | 
58 |  | - | 
59 | 51 | static NPY_TLS int npy_promotion_state = NPY_USE_LEGACY_PROMOTION;  | 
60 | 52 | 
 
  | 
61 | 53 | NPY_NO_EXPORT int  | 
@@ -92,13 +84,14 @@ npy_give_promotion_warnings(void)  | 
92 | 84 | 
 
  | 
93 | 85 |     npy_cache_import(  | 
94 | 86 |             "numpy._core._ufunc_config", "NO_NEP50_WARNING",  | 
95 |  | -            &NO_NEP50_WARNING_CTX);  | 
96 |  | -    if (NO_NEP50_WARNING_CTX == NULL) {  | 
 | 87 | +            &npy_ma_global_data->NO_NEP50_WARNING);  | 
 | 88 | +    if (npy_ma_global_data->NO_NEP50_WARNING == NULL) {  | 
97 | 89 |         PyErr_WriteUnraisable(NULL);  | 
98 | 90 |         return 1;  | 
99 | 91 |     }  | 
100 | 92 | 
 
  | 
101 |  | -    if (PyContextVar_Get(NO_NEP50_WARNING_CTX, Py_False, &val) < 0) {  | 
 | 93 | +    if (PyContextVar_Get(npy_ma_global_data->NO_NEP50_WARNING,  | 
 | 94 | +                         Py_False, &val) < 0) {  | 
102 | 95 |         /* Errors should not really happen, but if it does assume we warn. */  | 
103 | 96 |         PyErr_WriteUnraisable(NULL);  | 
104 | 97 |         return 1;  | 
@@ -409,12 +402,7 @@ PyArray_GetCastFunc(PyArray_Descr *descr, int type_num)  | 
409 | 402 |             !PyTypeNum_ISCOMPLEX(type_num) &&  | 
410 | 403 |             PyTypeNum_ISNUMBER(type_num) &&  | 
411 | 404 |             !PyTypeNum_ISBOOL(type_num)) {  | 
412 |  | -        static PyObject *cls = NULL;  | 
413 |  | -        npy_cache_import("numpy.exceptions", "ComplexWarning", &cls);  | 
414 |  | -        if (cls == NULL) {  | 
415 |  | -            return NULL;  | 
416 |  | -        }  | 
417 |  | -        int ret = PyErr_WarnEx(cls,  | 
 | 405 | +        int ret = PyErr_WarnEx(npy_ma_global_data->ComplexWarning,  | 
418 | 406 |                 "Casting complex values to real discards "  | 
419 | 407 |                 "the imaginary part", 1);  | 
420 | 408 |         if (ret < 0) {  | 
@@ -2638,13 +2626,7 @@ complex_to_noncomplex_get_loop(  | 
2638 | 2626 |         PyArrayMethod_StridedLoop **out_loop, NpyAuxData **out_transferdata,  | 
2639 | 2627 |         NPY_ARRAYMETHOD_FLAGS *flags)  | 
2640 | 2628 | {  | 
2641 |  | -    static PyObject *cls = NULL;  | 
2642 |  | -    int ret;  | 
2643 |  | -    npy_cache_import("numpy.exceptions", "ComplexWarning", &cls);  | 
2644 |  | -    if (cls == NULL) {  | 
2645 |  | -        return -1;  | 
2646 |  | -    }  | 
2647 |  | -    ret = PyErr_WarnEx(cls,  | 
 | 2629 | +    int ret = PyErr_WarnEx(npy_ma_global_data->ComplexWarning,  | 
2648 | 2630 |             "Casting complex values to real discards "  | 
2649 | 2631 |             "the imaginary part", 1);  | 
2650 | 2632 |     if (ret < 0) {  | 
 | 
0 commit comments