-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24255 from charris/backport-24248
BUG: Factor out slow `getenv` call used for memory policy warning
- Loading branch information
Showing
5 changed files
with
49 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,9 @@ maintainer email: [email protected] | |
#include "binop_override.h" | ||
#include "array_coercion.h" | ||
|
||
|
||
NPY_NO_EXPORT npy_bool numpy_warn_if_no_mem_policy = 0; | ||
|
||
/*NUMPY_API | ||
Compute the size of an array (in number of items) | ||
*/ | ||
|
@@ -460,9 +463,8 @@ array_dealloc(PyArrayObject *self) | |
} | ||
} | ||
if (fa->mem_handler == NULL) { | ||
char *env = getenv("NUMPY_WARN_IF_NO_MEM_POLICY"); | ||
if ((env != NULL) && (strncmp(env, "1", 1) == 0)) { | ||
char const * msg = "Trying to dealloc data, but a memory policy " | ||
if (numpy_warn_if_no_mem_policy) { | ||
char const *msg = "Trying to dealloc data, but a memory policy " | ||
"is not set. If you take ownership of the data, you must " | ||
"set a base owning the data (e.g. a PyCapsule)."; | ||
WARN_IN_DEALLOC(PyExc_RuntimeWarning, msg); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters