[Python-checkins] r42838 - in python/trunk: Include/object.h Python/pythonrun.c Python/sysmodule.c
neal.norwitz
python-checkins at python.org
Sat Mar 4 20:58:14 CET 2006
Author: neal.norwitz
Date: Sat Mar 4 20:58:13 2006
New Revision: 42838
Modified:
python/trunk/Include/object.h
python/trunk/Python/pythonrun.c
python/trunk/Python/sysmodule.c
Log:
Use Py_ssize_t for _Py_RefTotal.
I tried to handle Win64 properly, but please review.
Modified: python/trunk/Include/object.h
==============================================================================
--- python/trunk/Include/object.h (original)
+++ python/trunk/Include/object.h Sat Mar 4 20:58:13 2006
@@ -568,7 +568,7 @@
* #ifdefs (we used to do that -- it was impenetrable).
*/
#ifdef Py_REF_DEBUG
-PyAPI_DATA(long) _Py_RefTotal;
+PyAPI_DATA(Py_ssize_t) _Py_RefTotal;
PyAPI_FUNC(void) _Py_NegativeRefcount(const char *fname,
int lineno, PyObject *op);
#define _Py_INC_REFTOTAL _Py_RefTotal++
Modified: python/trunk/Python/pythonrun.c
==============================================================================
--- python/trunk/Python/pythonrun.c (original)
+++ python/trunk/Python/pythonrun.c Sat Mar 4 20:58:13 2006
@@ -29,6 +29,16 @@
#include "windows.h"
#endif
+#ifndef Py_REF_DEBUG
+# define PRINT_TOTAL_REFS()
+#else /* Py_REF_DEBUG */
+# if defined(MS_WIN64)
+# define PRINT_TOTAL_REFS() fprintf(stderr, "[%zd refs]\n", _Py_RefTotal);
+# else /* ! MS_WIN64 */
+# define PRINT_TOTAL_REFS() fprintf(stderr, "[%ld refs]\n", _Py_RefTotal);
+# endif /* MS_WIN64 */
+#endif
+
extern char *Py_GetPath(void);
extern grammar _PyParser_Grammar; /* From graminit.c */
@@ -382,9 +392,7 @@
dump_counts();
#endif
-#ifdef Py_REF_DEBUG
- fprintf(stderr, "[%ld refs]\n", _Py_RefTotal);
-#endif
+ PRINT_TOTAL_REFS()
#ifdef Py_TRACE_REFS
/* Display all objects still alive -- this can invoke arbitrary
@@ -674,9 +682,7 @@
}
for (;;) {
ret = PyRun_InteractiveOneFlags(fp, filename, flags);
-#ifdef Py_REF_DEBUG
- fprintf(stderr, "[%ld refs]\n", _Py_RefTotal);
-#endif
+ PRINT_TOTAL_REFS()
if (ret == E_EOF)
return 0;
/*
Modified: python/trunk/Python/sysmodule.c
==============================================================================
--- python/trunk/Python/sysmodule.c (original)
+++ python/trunk/Python/sysmodule.c Sat Mar 4 20:58:13 2006
@@ -604,7 +604,7 @@
static PyObject *
sys_gettotalrefcount(PyObject *self)
{
- return PyInt_FromLong(_Py_RefTotal);
+ return PyInt_FromSsize_t(_Py_RefTotal);
}
#endif /* Py_TRACE_REFS */
More information about the Python-checkins
mailing list