summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Include/weakrefobject.h2
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/_weakref.c6
-rw-r--r--Objects/weakrefobject.c4
4 files changed, 9 insertions, 6 deletions
diff --git a/Include/weakrefobject.h b/Include/weakrefobject.h
index daf490f..0a659b0 100644
--- a/Include/weakrefobject.h
+++ b/Include/weakrefobject.h
@@ -62,7 +62,7 @@ PyAPI_FUNC(PyObject *) PyWeakref_NewProxy(PyObject *ob,
PyObject *callback);
PyAPI_FUNC(PyObject *) PyWeakref_GetObject(PyObject *ref);
-PyAPI_FUNC(long) _PyWeakref_GetWeakrefCount(PyWeakReference *head);
+PyAPI_FUNC(Py_ssize_t) _PyWeakref_GetWeakrefCount(PyWeakReference *head);
PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self);
diff --git a/Misc/NEWS b/Misc/NEWS
index f2a318e..81f7ca4 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.5 beta 3?
Core and builtins
-----------------
+- _PyWeakref_GetWeakrefCount() now returns a Py_ssize_t, it previously
+ returned a long (see PEP 353).
+
- Bug #1515471: string.replace() accepts character buffers again.
- Add PyErr_WarnEx() so C code can pass the stacklevel to warnings.warn().
diff --git a/Modules/_weakref.c b/Modules/_weakref.c
index 2dfdc14..1712f12 100644
--- a/Modules/_weakref.c
+++ b/Modules/_weakref.c
@@ -17,7 +17,7 @@ weakref_getweakrefcount(PyObject *self, PyObject *object)
if (PyType_SUPPORTS_WEAKREFS(object->ob_type)) {
PyWeakReference **list = GET_WEAKREFS_LISTPTR(object);
- result = PyInt_FromLong(_PyWeakref_GetWeakrefCount(*list));
+ result = PyInt_FromSsize_t(_PyWeakref_GetWeakrefCount(*list));
}
else
result = PyInt_FromLong(0);
@@ -37,12 +37,12 @@ weakref_getweakrefs(PyObject *self, PyObject *object)
if (PyType_SUPPORTS_WEAKREFS(object->ob_type)) {
PyWeakReference **list = GET_WEAKREFS_LISTPTR(object);
- long count = _PyWeakref_GetWeakrefCount(*list);
+ Py_ssize_t count = _PyWeakref_GetWeakrefCount(*list);
result = PyList_New(count);
if (result != NULL) {
PyWeakReference *current = *list;
- long i;
+ Py_ssize_t i;
for (i = 0; i < count; ++i) {
PyList_SET_ITEM(result, i, (PyObject *) current);
Py_INCREF(current);
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index bbeb3c0..826f571 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -6,10 +6,10 @@
((PyWeakReference **) PyObject_GET_WEAKREFS_LISTPTR(o))
-long
+Py_ssize_t
_PyWeakref_GetWeakrefCount(PyWeakReference *head)
{
- long count = 0;
+ Py_ssize_t count = 0;
while (head != NULL) {
++count;