[Python-checkins] CVS: python/dist/src/Modules cPickle.c,2.73,2.73.2.1

Guido van Rossum gvanrossum@users.sourceforge.net
2001年12月21日 07:26:08 -0800


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv1502
Modified Files:
 Tag: release22-branch
	cPickle.c 
Log Message:
We go down 2000 recursion levels before we start getting suspicious
about recursive data structures in 'fast' mode. Jack is reporting
mysterious crashes in test_cpickle that could easily be stack
overflows (and test_cpickle exercises the limit).
Let's make the limit 50, but configurable by defining
PY_CPICKLE_FAST_LIMIT when cPickle is compiled.
Note that even the most hairy nested data structures don't nest this
deep, *except* when you use Python object references to implement
linked lists. So this shouldn't slow down the performance of fast
pickling, I think.
Index: cPickle.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v
retrieving revision 2.73
retrieving revision 2.73.2.1
diff -C2 -d -r2.73 -r2.73.2.1
*** cPickle.c	2001年12月19日 16:56:54	2.73
--- cPickle.c	2001年12月21日 15:26:05	2.73.2.1
***************
*** 322,326 ****
 } Picklerobject;
 
! #define FAST_LIMIT 2000
 
 staticforward PyTypeObject Picklertype;
--- 322,328 ----
 } Picklerobject;
 
! #ifndef PY_CPICKLE_FAST_LIMIT
! #define PY_CPICKLE_FAST_LIMIT 50
! #endif
 
 staticforward PyTypeObject Picklertype;
***************
*** 892,896 ****
 {
 /* if fast_container < 0, we're doing an error exit. */
! if (++self->fast_container >= FAST_LIMIT) {
 	PyObject *key = NULL;
 	if (self->fast_memo == NULL) {
--- 894,898 ----
 {
 /* if fast_container < 0, we're doing an error exit. */
! if (++self->fast_container >= PY_CPICKLE_FAST_LIMIT) {
 	PyObject *key = NULL;
 	if (self->fast_memo == NULL) {
***************
*** 922,926 ****
 fast_save_leave(Picklerobject *self, PyObject *obj)
 {
! if (self->fast_container-- >= FAST_LIMIT) {
 	PyObject *key = PyLong_FromVoidPtr(obj);
 	if (key == NULL)
--- 924,928 ----
 fast_save_leave(Picklerobject *self, PyObject *obj)
 {
! if (self->fast_container-- >= PY_CPICKLE_FAST_LIMIT) {
 	PyObject *key = PyLong_FromVoidPtr(obj);
 	if (key == NULL)

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