[Python-checkins] python/dist/src/Modules cPickle.c,2.130,2.131

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
2003年2月13日 07:44:48 -0800


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv24734/Modules
Modified Files:
	cPickle.c 
Log Message:
Added a HIGHEST_PROTOCOL module attribute to pickle and cPickle.
Index: cPickle.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v
retrieving revision 2.130
retrieving revision 2.131
diff -C2 -d -r2.130 -r2.131
*** cPickle.c	12 Feb 2003 05:28:58 -0000	2.130
--- cPickle.c	13 Feb 2003 15:44:41 -0000	2.131
***************
*** 16,20 ****
 
 /* Bump this when new opcodes are added to the pickle protocol. */
! #define CURRENT_PROTOCOL_NUMBER 2
 
 /*
--- 16,20 ----
 
 /* Bump this when new opcodes are added to the pickle protocol. */
! #define HIGHEST_PROTOCOL 2
 
 /*
***************
*** 2744,2752 ****
 
 	if (proto < 0)
! 		proto = CURRENT_PROTOCOL_NUMBER;
! 	if (proto > CURRENT_PROTOCOL_NUMBER) {
 		PyErr_Format(PyExc_ValueError, "pickle protocol %d asked for; "
 			 "the highest available protocol is %d",
! 			 proto, CURRENT_PROTOCOL_NUMBER);
 		return NULL;
 	}
--- 2744,2752 ----
 
 	if (proto < 0)
! 		proto = HIGHEST_PROTOCOL;
! 	if (proto > HIGHEST_PROTOCOL) {
 		PyErr_Format(PyExc_ValueError, "pickle protocol %d asked for; "
 			 "the highest available protocol is %d",
! 			 proto, HIGHEST_PROTOCOL);
 		return NULL;
 	}
***************
*** 4309,4313 ****
 	 */
 	assert(i >= 0);
! 	if (i <= CURRENT_PROTOCOL_NUMBER)
 		return 0;
 
--- 4309,4313 ----
 	 */
 	assert(i >= 0);
! 	if (i <= HIGHEST_PROTOCOL)
 		return 0;
 
***************
*** 5562,5565 ****
--- 5562,5569 ----
 	}
 	Py_DECREF(di);
+ 
+ 	i = PyModule_AddIntConstant(m, "HIGHEST_PROTOCOL", HIGHEST_PROTOCOL);
+ 	if (i < 0)
+ 		return;
 
 	/* These are purely informational; no code uses them. */

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