33
33
#include "dragon4.h"
34
34
#include "npy_longdouble.h"
35
35
#include "npy_buffer.h"
36
+ #include "npy_static_data.h"
36
37
#include "multiarraymodule.h"
37
38
38
39
#include <stdlib.h>
39
40
40
41
#include "binop_override.h"
41
42
42
- /* determines if legacy mode is enabled, global set in multiarraymodule.c */
43
- extern int npy_legacy_print_mode ;
44
-
45
43
/*
46
44
* used for allocating a single scalar, so use the default numpy
47
45
* memory allocators instead of the (maybe) user overrides
@@ -338,7 +336,7 @@ genint_type_repr(PyObject *self)
338
336
if (value_string == NULL ) {
339
337
return NULL ;
340
338
}
341
- if (npy_legacy_print_mode <= 125 ) {
339
+ if (npy_thread_unsafe_state . legacy_print_mode <= 125 ) {
342
340
return value_string ;
343
341
}
344
342
@@ -375,7 +373,7 @@ genbool_type_str(PyObject *self)
375
373
static PyObject *
376
374
genbool_type_repr (PyObject * self )
377
375
{
378
- if (npy_legacy_print_mode <= 125 ) {
376
+ if (npy_thread_unsafe_state . legacy_print_mode <= 125 ) {
379
377
return genbool_type_str (self );
380
378
}
381
379
return PyUnicode_FromString (
@@ -501,7 +499,7 @@ stringtype_@form@(PyObject *self)
501
499
if (ret == NULL ) {
502
500
return NULL ;
503
501
}
504
- if (npy_legacy_print_mode > 125 ) {
502
+ if (npy_thread_unsafe_state . legacy_print_mode > 125 ) {
505
503
Py_SETREF (ret , PyUnicode_FromFormat ("np.bytes_(%S)" , ret ));
506
504
}
507
505
#endif /* IS_repr */
@@ -548,7 +546,7 @@ unicodetype_@form@(PyObject *self)
548
546
if (ret == NULL ) {
549
547
return NULL ;
550
548
}
551
- if (npy_legacy_print_mode > 125 ) {
549
+ if (npy_thread_unsafe_state . legacy_print_mode > 125 ) {
552
550
Py_SETREF (ret , PyUnicode_FromFormat ("np.str_(%S)" , ret ));
553
551
}
554
552
#endif /* IS_repr */
@@ -629,7 +627,7 @@ voidtype_repr(PyObject *self)
629
627
/* Python helper checks for the legacy mode printing */
630
628
return _void_scalar_to_string (self , 1 );
631
629
}
632
- if (npy_legacy_print_mode > 125 ) {
630
+ if (npy_thread_unsafe_state . legacy_print_mode > 125 ) {
633
631
return _void_to_hex (s -> obval , s -> descr -> elsize , "np.void(b'" , "\\x" , "')" );
634
632
}
635
633
else {
@@ -681,7 +679,7 @@ datetimetype_repr(PyObject *self)
681
679
*/
682
680
if ((scal -> obmeta .num == 1 && scal -> obmeta .base != NPY_FR_h ) ||
683
681
scal -> obmeta .base == NPY_FR_GENERIC ) {
684
- if (npy_legacy_print_mode > 125 ) {
682
+ if (npy_thread_unsafe_state . legacy_print_mode > 125 ) {
685
683
ret = PyUnicode_FromFormat ("np.datetime64('%s')" , iso );
686
684
}
687
685
else {
@@ -693,7 +691,7 @@ datetimetype_repr(PyObject *self)
693
691
if (meta == NULL ) {
694
692
return NULL ;
695
693
}
696
- if (npy_legacy_print_mode > 125 ) {
694
+ if (npy_thread_unsafe_state . legacy_print_mode > 125 ) {
697
695
ret = PyUnicode_FromFormat ("np.datetime64('%s','%S')" , iso , meta );
698
696
}
699
697
else {
@@ -737,7 +735,7 @@ timedeltatype_repr(PyObject *self)
737
735
738
736
/* The metadata unit */
739
737
if (scal -> obmeta .base == NPY_FR_GENERIC ) {
740
- if (npy_legacy_print_mode > 125 ) {
738
+ if (npy_thread_unsafe_state . legacy_print_mode > 125 ) {
741
739
ret = PyUnicode_FromFormat ("np.timedelta64(%S)" , val );
742
740
}
743
741
else {
@@ -750,7 +748,7 @@ timedeltatype_repr(PyObject *self)
750
748
Py_DECREF (val );
751
749
return NULL ;
752
750
}
753
- if (npy_legacy_print_mode > 125 ) {
751
+ if (npy_thread_unsafe_state . legacy_print_mode > 125 ) {
754
752
ret = PyUnicode_FromFormat ("np.timedelta64(%S,'%S')" , val , meta );
755
753
}
756
754
else {
@@ -1052,7 +1050,7 @@ static PyObject *
1052
1050
npy_bool sign )
1053
1051
{
1054
1052
1055
- if (npy_legacy_print_mode <= 113 ) {
1053
+ if (npy_thread_unsafe_state . legacy_print_mode <= 113 ) {
1056
1054
return legacy_ @name @_format @kind @(val );
1057
1055
}
1058
1056
@@ -1083,7 +1081,7 @@ static PyObject *
1083
1081
if (string == NULL ) {
1084
1082
return NULL ;
1085
1083
}
1086
- if (npy_legacy_print_mode > 125 ) {
1084
+ if (npy_thread_unsafe_state . legacy_print_mode > 125 ) {
1087
1085
Py_SETREF (string , PyUnicode_FromFormat ("@repr_format@" , string ));
1088
1086
}
1089
1087
#endif /* IS_repr */
@@ -1098,7 +1096,7 @@ c@name@type_@kind@(PyObject *self)
1098
1096
npy_c @name @ val = PyArrayScalar_VAL (self , C @Name @);
1099
1097
TrimMode trim = TrimMode_DptZeros ;
1100
1098
1101
- if (npy_legacy_print_mode <= 113 ) {
1099
+ if (npy_thread_unsafe_state . legacy_print_mode <= 113 ) {
1102
1100
return legacy_c @name @_format @kind @(val );
1103
1101
}
1104
1102
@@ -1111,7 +1109,7 @@ c@name@type_@kind@(PyObject *self)
1111
1109
#ifdef IS_str
1112
1110
ret = PyUnicode_FromFormat ("%Sj" , istr );
1113
1111
#else /* IS_repr */
1114
- if (npy_legacy_print_mode <= 125 ) {
1112
+ if (npy_thread_unsafe_state . legacy_print_mode <= 125 ) {
1115
1113
ret = PyUnicode_FromFormat ("%Sj" , istr );
1116
1114
}
1117
1115
else {
@@ -1159,7 +1157,7 @@ c@name@type_@kind@(PyObject *self)
1159
1157
#ifdef IS_str
1160
1158
string = PyUnicode_FromFormat ("(%S%Sj)" , rstr , istr );
1161
1159
#else /* IS_repr */
1162
- if (npy_legacy_print_mode > 125 ) {
1160
+ if (npy_thread_unsafe_state . legacy_print_mode > 125 ) {
1163
1161
string = PyUnicode_FromFormat ("@crepr_format@" , rstr , istr );
1164
1162
}
1165
1163
else {
@@ -1184,7 +1182,7 @@ halftype_@kind@(PyObject *self)
1184
1182
float floatval = npy_half_to_float (val );
1185
1183
float absval ;
1186
1184
1187
- if (npy_legacy_print_mode <= 113 ) {
1185
+ if (npy_thread_unsafe_state . legacy_print_mode <= 113 ) {
1188
1186
return legacy_float_format @kind @(floatval );
1189
1187
}
1190
1188
@@ -1200,7 +1198,7 @@ halftype_@kind@(PyObject *self)
1200
1198
#ifdef IS_str
1201
1199
return string ;
1202
1200
#else
1203
- if (string == NULL || npy_legacy_print_mode <= 125 ) {
1201
+ if (string == NULL || npy_thread_unsafe_state . legacy_print_mode <= 125 ) {
1204
1202
return string ;
1205
1203
}
1206
1204
PyObject * res = PyUnicode_FromFormat ("np.float16(%S)" , string );
0 commit comments