~pythonregexp2.7/python/issue2636-11

« back to all changes in this revision

Viewing changes to Objects/weakrefobject.c

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-09-21 17:53:26 UTC
  • mfrom: (39025.1.14 Regexp-2.7)
  • Revision ID: darklord@timehorse.com-20080921175326-92vaej2hc3yuecxb
Merged in changes from the core Regexp branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
326
326
    if (parse_weakref_init_args("__init__", args, kwargs, &tmp, &tmp))
327
327
        return 0;
328
328
    else
329
 
        return 1;
 
329
        return -1;
330
330
}
331
331
 
332
332
 
907
907
            current->wr_callback = NULL;
908
908
            clear_weakref(current);
909
909
            if (callback != NULL) {
910
 
                handle_callback(current, callback);
 
910
                if (current->ob_refcnt > 0)
 
911
                    handle_callback(current, callback);
911
912
                Py_DECREF(callback);
912
913
            }
913
914
        }
925
926
            for (i = 0; i < count; ++i) {
926
927
                PyWeakReference *next = current->wr_next;
927
928
 
928
 
                Py_INCREF(current);
929
 
                PyTuple_SET_ITEM(tuple, i * 2, (PyObject *) current);
930
 
                PyTuple_SET_ITEM(tuple, i * 2 + 1, current->wr_callback);
 
929
                if (current->ob_refcnt > 0)
 
930
                {
 
931
                    Py_INCREF(current);
 
932
                    PyTuple_SET_ITEM(tuple, i * 2, (PyObject *) current);
 
933
                    PyTuple_SET_ITEM(tuple, i * 2 + 1, current->wr_callback);
 
934
                }
 
935
                else {
 
936
                    Py_DECREF(current->wr_callback);
 
937
                }
931
938
                current->wr_callback = NULL;
932
939
                clear_weakref(current);
933
940
                current = next;
935
942
            for (i = 0; i < count; ++i) {
936
943
                PyObject *callback = PyTuple_GET_ITEM(tuple, i * 2 + 1);
937
944
 
 
945
                /* The tuple may have slots left to NULL */
938
946
                if (callback != NULL) {
939
947
                    PyObject *item = PyTuple_GET_ITEM(tuple, i * 2);
940
948
                    handle_callback((PyWeakReference *)item, callback);