[Python-checkins] python/dist/src/Objects dictobject.c,2.138,2.139

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
2003年2月14日 19:01:15 -0800


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1:/tmp/cvs-serv13821/python/Objects
Modified Files:
	dictobject.c 
Log Message:
cPickle.c, load_build(): Taught cPickle how to pick apart
the optional proto 2 slot state.
pickle.py, load_build(): CAUTION: Noted that cPickle's
load_build and pickle's load_build really don't do the same
things with the state, and didn't before this patch either.
cPickle never tries to do .update(), and has no backoff if
instance.__dict__ can't be retrieved. There are no tests
that can tell the difference, and part of what cPickle's
load_build() did looked accidental to me, so I don't know
what the true intent is here.
pickletester.py, test_pickle.py: Got rid of the hack for
exempting cPickle from running some of the proto 2 tests.
dictobject.c, PyDict_Next(): documented intended use.
Index: dictobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v
retrieving revision 2.138
retrieving revision 2.139
diff -C2 -d -r2.138 -r2.139
*** dictobject.c	29 Dec 2002 16:33:11 -0000	2.138
--- dictobject.c	15 Feb 2003 03:01:11 -0000	2.139
***************
*** 643,647 ****
 }
 
! /* CAUTION: In general, it isn't safe to use PyDict_Next in a loop that
 * mutates the dict. One exception: it is safe if the loop merely changes
 * the values associated with the keys (but doesn't insert new keys or
--- 643,657 ----
 }
 
! /*
! * Iterate over a dict. Use like so:
! *
! * int i;
! * PyObject *key, *value;
! * i = 0; # important! i should not otherwise be changed by you
! * while (PyDict_Next(yourdict, &i, &key, &value) {
! * Refer to borrowed references in key and value.
! * }
! *
! * CAUTION: In general, it isn't safe to use PyDict_Next in a loop that
 * mutates the dict. One exception: it is safe if the loop merely changes
 * the values associated with the keys (but doesn't insert new keys or

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