8000 MAINT: respond to review comments · numpy/numpy@dabfe59 · GitHub
[go: up one dir, main page]

Skip to content

Commit dabfe59

Browse files
committed
MAINT: respond to review comments
1 parent b6af99a commit dabfe59

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

numpy/_core/src/common/npy_argparse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ NPY_NO_EXPORT int init_argparse_mutex(void);
3838
* The sole purpose of this macro is to hide the argument parsing cache.
3939
* Since this cache must be static, this also removes a source of error.
4040
*/
41-
#define NPY_PREPARE_ARGPARSER static _NpyArgParserCache __argparse_cache = {-1}
41+
#define NPY_PREPARE_ARGPARSER static _NpyArgParserCache __argparse_cache;
4242

4343
/**
4444
* Macro to help with argument parsing.

numpy/_core/src/common/npy_import.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,16 @@ npy_import(const char *module, const char *attr)
8282
static inline int
8383
npy_cache_import_runtime(const char *module, const char *attr, PyObject **obj) {
8484
if (!npy_atomic_load_ptr(obj)) {
85+
PyObject* value = npy_import(module, attr);
86+
if (value == NULL) {
87+
return -1;
88+
}
8589
PyThread_acquire_lock(npy_runtime_imports.import_mutex, WAIT_LOCK);
8690
if (!npy_atomic_load_ptr(obj)) {
87-
npy_atomic_store_ptr(obj, npy_import(module, attr));
88-
if (obj == NULL) {
89-
return -1;
90-
}
91+
npy_atomic_store_ptr(obj, Py_NewRef(value));
9192
}
9293
PyThread_release_lock(npy_runtime_imports.import_mutex);
94+
Py_DECREF(value);
9395
}
9496
return 0;
9597
}

0 commit comments

Comments
 (0)
0