diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-04-28 14:11:55 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-04-28 14:11:55 +0300 |
commit | 4aa17daa71537210b088b92633f3abcb2a748ce7 (patch) | |
tree | 4d91dbcbcf903de08d82aa5977c31c02fcc65b69 /Python/pythonrun.c | |
parent | 7d7859eb26264204a9bb8e6fb14078928e532a72 (diff) | |
parent | 43717164f370047c58879fedb78fb0d1673de795 (diff) | |
download | cpython-4aa17daa71537210b088b92633f3abcb2a748ce7.tar.gz |
Issue #17857: Prevent build failures with pre-3.5.0 versions of sqlite3,
such as was shipped with Centos 5 and Mac OS X 10.4.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index dd32017574..0cd695f36e 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -35,12 +35,30 @@ #define PATH_MAX MAXPATHLEN #endif +#ifdef Py_REF_DEBUG +static +void _print_total_refs(void) { + 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 |