diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-04-22 22:54:16 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-04-22 22:54:16 +0300 |
commit | 3fbd10565cefc42542cb32a34053762d60379513 (patch) | |
tree | aff49df1b80f66e9c699a0a19a428f0e9ecc1c7b /Python/pythonrun.c | |
parent | 1685a2870886639377a90fbcd85b25af4aee3341 (diff) | |
parent | 11135e3133e7d8054b37716784babba98165861c (diff) | |
download | cpython-3fbd10565cefc42542cb32a34053762d60379513.tar.gz |
Issue #11714: Use 'with' statements to assure a Semaphore releases a
condition variable. Original patch by Thomas Rachel.
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 |