[Python-checkins] python/dist/src/Objects weakrefobject.c, 1.18, 1.19

fdrake at users.sourceforge.net fdrake at users.sourceforge.net
Tue Aug 3 16:47:28 CEST 2004


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv924/Objects
Modified Files:
	weakrefobject.c 
Log Message:
Be more careful about maintaining the invariants; it was actually
possible that the callback-less flavors of the ref or proxy could have
been added during GC, so we don't want to replace them.
Index: weakrefobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/weakrefobject.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** weakrefobject.c	8 Jul 2004 01:22:31 -0000	1.18
--- weakrefobject.c	3 Aug 2004 14:47:25 -0000	1.19
***************
*** 748,758 ****
 result = new_weakref(ob, callback);
 if (result != NULL) {
 if (callback == NULL) {
! insert_head(result, list);
 }
 else {
 PyWeakReference *prev;
 
- get_basic_refs(*list, &ref, &proxy);
 prev = (proxy == NULL) ? ref : proxy;
 if (prev == NULL)
--- 748,768 ----
 result = new_weakref(ob, callback);
 if (result != NULL) {
+ get_basic_refs(*list, &ref, &proxy);
 if (callback == NULL) {
! if (ref == NULL)
! insert_head(result, list);
! else {
! /* Someone else added a ref without a callback
! during GC. Return that one instead of this one
! to avoid violating the invariants of the list
! of weakrefs for ob. */
! Py_DECREF(result);
! Py_INCREF(ref);
! result = ref;
! }
 }
 else {
 PyWeakReference *prev;
 
 prev = (proxy == NULL) ? ref : proxy;
 if (prev == NULL)
***************
*** 804,809 ****
 result->ob_type = &_PyWeakref_ProxyType;
 get_basic_refs(*list, &ref, &proxy);
! if (callback == NULL)
 prev = ref;
 else
 prev = (proxy == NULL) ? ref : proxy;
--- 814,829 ----
 result->ob_type = &_PyWeakref_ProxyType;
 get_basic_refs(*list, &ref, &proxy);
! if (callback == NULL) {
! if (proxy != NULL) {
! /* Someone else added a proxy without a callback
! during GC. Return that one instead of this one
! to avoid violating the invariants of the list
! of weakrefs for ob. */
! Py_DECREF(result);
! Py_INCREF(result = proxy);
! goto skip_insert;
! }
 prev = ref;
+ }
 else
 prev = (proxy == NULL) ? ref : proxy;
***************
*** 813,816 ****
--- 833,838 ----
 else
 insert_after(result, prev);
+ skip_insert:
+ ;
 }
 }


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /