@@ -336,7 +336,11 @@ genint_type_repr(PyObject *self)
336
336
if (value_string == NULL ) {
337
337
return NULL ;
338
338
}
339
- if (get_legacy_print_mode () <= 125 ) {
339
+ int legacy_print_mode = get_legacy_print_mode ();
340
+ if (legacy_print_mode == -1 ) {
341
+ return NULL ;
342
+ }
343
+ if (legacy_print_mode <= 125 ) {
340
344
return value_string ;
341
345
}
342
346
@@ -373,7 +377,11 @@ genbool_type_str(PyObject *self)
373
377
static PyObject *
374
378
genbool_type_repr (PyObject * self )
375
379
{
376
- if (get_legacy_print_mode () <= 125 ) {
380
+ int legacy_print_mode = get_legacy_print_mode ();
381
+ if (legacy_print_mode == -1 ) {
382
+ return NULL ;
383
+ }
384
+ if (legacy_print_mode <= 125 ) {
377
385
return genbool_type_str (self );
378
386
}
379
387
return PyUnicode_FromString (
@@ -499,7 +507,11 @@ stringtype_@form@(PyObject *self)
499
507
if (ret == NULL ) {
500
508
return NULL ;
501
509
}
502
- if (get_legacy_print_mode () > 125 ) {
510
+ int legacy_print_mode = get_legacy_print_mode ();
511
+ if (legacy_print_mode == -1 ) {
512
+ return NULL ;
513
+ }
514
+ if (legacy_print_mode > 125 ) {
503
515
Py_SETREF (ret , PyUnicode_FromFormat ("np.bytes_(%S)" , ret ));
504
516
}
505
517
#endif /* IS_repr */
@@ -546,7 +558,11 @@ unicodetype_@form@(PyObject *self)
546
558
if (ret == NULL ) {
547
559
return NULL ;
548
560
}
549
- if (get_legacy_print_mode () > 125 ) {
561
+ int legacy_print_mode = get_legacy_print_mode ();
562
+ if (legacy_print_mode == -1 ) {
563
+ return NULL ;
564
+ }
565
+ if (legacy_print_mode > 125 ) {
550
566
Py_SETREF (ret , PyUnicode_FromFormat ("np.str_(%S)" , ret ));
551
567
}
552
568
#endif /* IS_repr */
@@ -626,7 +642,11 @@ voidtype_repr(PyObject *self)
626
642
/* Python helper checks for the legacy mode printing */
627
643
return _void_scalar_to_string (self , 1 );
628
644
}
629
- if (get_legacy_print_mode () > 125 ) {
645
+ int legacy_print_mode = get_legacy_print_mode ();
646
+ if (legacy_print_mode == -1 ) {
647
+ return NULL ;
648
+ }
649
+ if (legacy_print_mode > 125 ) {
630
650
return _void_to_hex (s -> obval , s -> descr -> elsize , "np.void(b'" , "\\x" , "')" );
631
651
}
632
652
else {
@@ -678,7 +698,11 @@ datetimetype_repr(PyObject *self)
678
698
*/
679
699
if ((scal -> obmeta .num == 1 && scal -> obmeta .base != NPY_FR_h ) ||
680
700
scal -> obmeta .base == NPY_FR_GENERIC ) {
681
- if (get_legacy_print_mode () > 125 ) {
701
+ int legacy_print_mode = get_legacy_print_mode ();
702
+ if (legacy_print_mode == -1 ) {
703
+ return NULL ;
704
+ }
705
+ if (legacy_print_mode > 125 ) {
682
706
ret = PyUnicode_FromFormat ("np.datetime64('%s')" , iso );
683
707
}
684
708
else {
@@ -690,7 +714,11 @@ datetimetype_repr(PyObject *self)
690
714
if (meta == NULL ) {
691
715
return NULL ;
692
716
}
693
- if (get_legacy_print_mode () > 125 ) {
717
+ int legacy_print_mode = get_legacy_print_mode ();
718
+ if (legacy_print_mode == -1 ) {
719
+ return NULL ;
720
+ }
721
+ if (legacy_print_mode > 125 ) {
694
722
ret = PyUnicode_FromFormat ("np.datetime64('%s','%S')" , iso , meta );
695
723
}
696
724
else {
@@ -734,7 +762,11 @@ timedeltatype_repr(PyObject *self)
734
762
735
763
/* The metadata unit */
736
764
if (scal -> obmeta .base == NPY_FR_GENERIC ) {
737
- if (get_legacy_print_mode () > 125 ) {
765
+ int legacy_print_mode = get_legacy_print_mode ();
766
+ if (legacy_print_mode == -1 ) {
767
+ return NULL ;
768
+ }
769
+ if (legacy_print_mode > 125 ) {
738
770
ret = PyUnicode_FromFormat ("np.timedelta64(%S)" , val );
739
771
}
740
772
else {
@@ -747,7 +779,11 @@ timedeltatype_repr(PyObject *self)
747
779
Py_DECREF (val );
748
780
return NULL ;
749
781
}
750
- if (get_legacy_print_mode () > 125 ) {
782
+ int legacy_print_mode = get_legacy_print_mode ();
783
+ if (legacy_print_mode == -1 ) {
784
+ return NULL ;
785
+ }
786
+ if (legacy_print_mode > 125 ) {
751
787
ret = PyUnicode_FromFormat ("np.timedelta64(%S,'%S')" , val , meta );
752
788
}
753
789
else {
@@ -1049,7 +1085,11 @@ static PyObject *
1049
1085
npy_bool sign )
1050
1086
{
1051
1087
1052
- if (get_legacy_print_mode () <= 113 ) {
1088
+ int legacy_print_mode = get_legacy_print_mode ();
1089
+ if (legacy_print_mode == -1 ) {
1090
+ return NULL ;
1091
+ }
1092
+ if (legacy_print_mode <= 113 ) {
1053
1093
return legacy_ @name @_format @kind @(val );
1054
1094
}
1055
1095
@@ -1080,7 +1120,11 @@ static PyObject *
1080
1120
if (string == NULL ) {
1081
1121
return NULL ;
1082
1122
}
1083
- if (get_legacy_print_mode () > 125 ) {
1123
+ int legacy_print_mode = get_legacy_print_mode ();
1124
+ if (legacy_print_mode == -1 ) {
1125
+ return NULL ;
1126
+ }
1127
+ if (legacy_print_mode > 125 ) {
1084
1128
Py_SETREF (string , PyUnicode_FromFormat ("@repr_format@" , string ));
1085
1129
}
1086
1130
#endif /* IS_repr */
@@ -1095,7 +1139,11 @@ c@name@type_@kind@(PyObject *self)
1095
1139
npy_c @name @ val = PyArrayScalar_VAL (self , C @Name @);
1096
1140
TrimMode trim = TrimMode_DptZeros ;
1097
1141
1098
- if (get_legacy_print_mode () <= 113 ) {
1142
+ int legacy_print_mode = get_legacy_print_mode ();
1143
+ if (legacy_print_mode == -1 ) {
1144
+ return NULL ;
1145
+ }
1146
+ if (legacy_print_mode <= 113 ) {
1099
1147
return legacy_c @name @_format @kind @(val );
1100
1148
}
1101
1149
@@ -1108,7 +1156,11 @@ c@name@type_@kind@(PyObject *self)
1108
1156
#ifdef IS_str
1109
1157
ret = PyUnicode_FromFormat ("%Sj" , istr );
1110
1158
#else /* IS_repr */
1111
- if (get_legacy_print_mode () <= 125 ) {
1159
+ int legacy_print_mode = get_legacy_print_mode ();
1160
+ if (legacy_print_mode == -1 ) {
1161
+ return NULL ;
1162
+ }
1163
+ if (legacy_print_mode <= 125 ) {
1112
1164
ret = PyUnicode_FromFormat ("%Sj" , istr );
1113
1165
}
1114
1166
else {
@@ -1156,7 +1208,11 @@ c@name@type_@kind@(PyObject *self)
1156
1208
#ifdef IS_str
1157
1209
string = PyUnicode_FromFormat ("(%S%Sj)" , rstr , istr );
1158
1210
#else /* IS_repr */
1159
- if (get_legacy_print_mode () > 125 ) {
1211
+ legacy_print_mode = get_legacy_print_mode ();
1212
+ if (legacy_print_mode == -1 ) {
1213
+ return NULL ;
1214
+ }
1215
+ if (legacy_print_mode > 125 ) {
1160
1216
string = PyUnicode_FromFormat ("@crepr_format@" , rstr , istr );
1161
1217
}
1162
1218
else {
@@ -1181,7 +1237,11 @@ halftype_@kind@(PyObject *self)
1181
1237
float floatval = npy_half_to_float (val );
1182
1238
float absval ;
1183
1239
1184
- if (get_legacy_print_mode () <= 113 ) {
1240
+ int legacy_print_mode = get_legacy_print_mode ();
1241
+ if (legacy_print_mode == -1 ) {
1242
+ return NULL ;
1243
+ }
1244
+ if (legacy_print_mode <= 113 ) {
1185
1245
return legacy_float_format @kind @(floatval );
1186
1246
}
1187
1247
@@ -1197,7 +1257,11 @@ halftype_@kind@(PyObject *self)
1197
1257
#ifdef IS_str
1198
1258
return string ;
1199
1259
#else
1200
- if (string == NULL || get_legacy_print_mode () <= 125 ) {
1260
+ legacy_print_mode = get_legacy_print_mode ();
1261
+ if (legacy_print_mode == -1 ) {
1262
+ return NULL ;
1263
+ }
1264
+ if (string == NULL || legacy_print_mode <= 125 ) {
1201
1265
return string ;
1202
1266
}
1203
1267
PyObject * res = PyUnicode_FromFormat ("np.float16(%S)" , string );
0 commit comments