diff options
author | Barry Warsaw <barry@python.org> | 2013-04-16 11:18:18 -0400 |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2013-04-16 11:18:18 -0400 |
commit | 2c14bba3747003c8ee38eb8664a32b1d69add706 (patch) | |
tree | 48832a2dae22bdae903c124e435a4b8e4534f815 /Python/pythonrun.c | |
parent | d27c7b1388545c65052f19020e4f2d82d2550ca4 (diff) | |
parent | 328616fecb4145a2265aee43b51c7fbfee2f1bc9 (diff) | |
download | cpython-2c14bba3747003c8ee38eb8664a32b1d69add706.tar.gz |
- Issue #17012: shutil.which() no longer fallbacks to the PATH environment
variable if empty path argument is specified. Patch by Serhiy Storchaka.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index dd32017574..751008ac30 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -35,12 +35,29 @@ #define PATH_MAX MAXPATHLEN #endif +#ifdef Py_REF_DEBUG +void _print_total_refs() { + PyObject *xoptions, *key, *value; + xoptions = PySys_GetXOptions(); + if (xoptions == NULL) + return; + key = PyUnicode_FromString("showrefcount"); + if (key == NULL) + return; + value = PyDict_GetItem(xoptions, key); + Py_DECREF(key); + if (value == Py_True) + fprintf(stderr, + "[%" PY_FORMAT_SIZE_T "d refs, " + "%" PY_FORMAT_SIZE_T "d blocks]\n", + _Py_GetRefTotal(), _Py_GetAllocatedBlocks()); +} +#endif + #ifndef Py_REF_DEBUG #define PRINT_TOTAL_REFS() #else /* Py_REF_DEBUG */ -#define PRINT_TOTAL_REFS() fprintf(stderr, \ - "[%" PY_FORMAT_SIZE_T "d refs]\n", \ - _Py_GetRefTotal()) +#define PRINT_TOTAL_REFS() _print_total_refs() #endif #ifdef __cplusplus |