@@ -58,6 +58,8 @@ typedef struct {
58
58
PyTypeObject * ArrayType ;
59
59
PyTypeObject * ArrayIterType ;
60
60
61
+ PyObject * array_reconstructor ;
62
+
61
63
PyObject * str_read ;
62
64
PyObject * str_write ;
63
65
PyObject * str___dict__ ;
@@ -2191,17 +2193,17 @@ array_array___reduce_ex___impl(arrayobject *self, PyTypeObject *cls,
2191
2193
PyObject * array_str ;
2192
2194
int typecode = self -> ob_descr -> typecode ;
2193
2195
int mformat_code ;
2194
- static PyObject * array_reconstructor = NULL ;
2195
2196
long protocol ;
2196
2197
2197
2198
array_state * state = get_array_state_by_class (cls );
2198
2199
assert (state != NULL );
2199
2200
2200
- if (array_reconstructor == NULL ) {
2201
- array_reconstructor = _PyImport_GetModuleAttrString (
2201
+ if (state -> array_reconstructor == NULL ) {
2202
+ state -> array_reconstructor = _PyImport_GetModuleAttrString (
2202
2203
"array" , "_array_reconstructor" );
2203
- if (array_reconstructor == NULL )
2204
+ if (state -> array_reconstructor == NULL ) {
2204
2205
return NULL ;
2206
+ }
2205
2207
}
2206
2208
2207
2209
if (!PyLong_Check (value )) {
@@ -2252,8 +2254,10 @@ array_array___reduce_ex___impl(arrayobject *self, PyTypeObject *cls,
2252
2254
Py_DECREF (dict );
2253
2255
return NULL ;
2254
2256
}
2257
+
2258
+ assert (state -> array_reconstructor != NULL );
2255
2259
result = Py_BuildValue (
2256
- "O(OCiN)O" , array_reconstructor , Py_TYPE (self ), typecode ,
2260
+ "O(OCiN)O" , state -> array_reconstructor , Py_TYPE (self ), typecode ,
2257
2261
mformat_code , array_str , dict );
2258
2262
Py_DECREF (dict );
2259
2263
return result ;
@@ -3013,6 +3017,7 @@ array_traverse(PyObject *module, visitproc visit, void *arg)
3013
3017
array_state * state = get_array_state (module );
3014
3018
Py_VISIT (state -> ArrayType );
3015
3019
Py_VISIT (state -> ArrayIterType );
3020
+ Py_VISIT (state -> array_reconstructor );
3016
3021
return 0 ;
3017
3022
}
3018
3023
@@ -3022,6 +3027,7 @@ array_clear(PyObject *module)
3022
3027
array_state * state = get_array_state (module );
3023
3028
Py_CLEAR (state -> ArrayType );
3024
3029
Py_CLEAR (state -> ArrayIterType );
3030
+ Py_CLEAR (state -> array_reconstructor );
3025
3031
Py_CLEAR (state -> str_read );
3026
3032
Py_CLEAR (state -> str_write );
3027
3033
Py_CLEAR (state -> str___dict__ );
@@ -3066,6 +3072,7 @@ array_modexec(PyObject *m)
3066
3072
PyObject * typecodes ;
3067
3073
const struct arraydescr * descr ;
3068
3074
3075
+ state -> array_reconstructor = NULL ;
3069
3076
/* Add interned strings */
3070
3077
ADD_INTERNED (state , read );
3071
3078
ADD_INTERNED (state , write );
0 commit comments