comparison Python/pythonrun.c @ 86965:55517661a053

Issue #19512: _print_total_refs() now uses an identifier to get "showrefcount" key from sys._xoptions
author Victor Stinner <victor.stinner@gmail.com>
date Wed, 06 Nov 2013 18:28:21 +0100
parents b5cc822d5bf0
children af822a6c9faf
comparison
equal deleted inserted replaced
86964:a2f42d57b91d 86965:55517661a053
36 #endif 36 #endif
37 37
38 #ifdef Py_REF_DEBUG 38 #ifdef Py_REF_DEBUG
39 static 39 static
40 void _print_total_refs(void) { 40 void _print_total_refs(void) {
41 PyObject *xoptions, *key, *value; 41 PyObject *xoptions, *value;
42 _Py_IDENTIFIER(showrefcount);
43
42 xoptions = PySys_GetXOptions(); 44 xoptions = PySys_GetXOptions();
43 if (xoptions == NULL) 45 if (xoptions == NULL)
44 return; 46 return;
45 key = PyUnicode_FromString("showrefcount"); 47 value = _PyDict_GetItemId(xoptions, &PyId_showrefcount);
46 if (key == NULL)
47 return;
48 value = PyDict_GetItem(xoptions, key);
49 Py_DECREF(key);
50 if (value == Py_True) 48 if (value == Py_True)
51 fprintf(stderr, 49 fprintf(stderr,
52 "[%" PY_FORMAT_SIZE_T "d refs, " 50 "[%" PY_FORMAT_SIZE_T "d refs, "
53 "%" PY_FORMAT_SIZE_T "d blocks]\n", 51 "%" PY_FORMAT_SIZE_T "d blocks]\n",
54 _Py_GetRefTotal(), _Py_GetAllocatedBlocks()); 52 _Py_GetRefTotal(), _Py_GetAllocatedBlocks());