[Python-checkins] python/dist/src/Modules cPickle.c,2.112,2.113
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Sun, 02 Feb 2003 09:59:13 -0800
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv7126/Modules
Modified Files:
cPickle.c
Log Message:
Implemented proto 2 NEWTRUE and NEWFALSE in cPickle.
Index: cPickle.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v
retrieving revision 2.112
retrieving revision 2.113
diff -C2 -d -r2.112 -r2.113
*** cPickle.c 2 Feb 2003 17:26:40 -0000 2.112
--- cPickle.c 2 Feb 2003 17:59:11 -0000 2.113
***************
*** 964,970 ****
long l = PyInt_AS_LONG((PyIntObject *)args);
! if ((*self->write_func)(self, buf[l], len[l]) < 0)
return -1;
-
return 0;
}
--- 964,974 ----
long l = PyInt_AS_LONG((PyIntObject *)args);
! if (self->proto >= 2) {
! char opcode = l ? NEWTRUE : NEWFALSE;
! if (self->write_func(self, &opcode, 1) < 0)
! return -1;
! }
! else if (self->write_func(self, buf[l], len[l]) < 0)
return -1;
return 0;
}
***************
*** 2790,2793 ****
--- 2794,2806 ----
}
+ static int
+ load_bool(Unpicklerobject *self, PyObject *boolean)
+ {
+ assert(boolean == Py_True || boolean == Py_False);
+ Py_INCREF(boolean);
+ PDATA_PUSH(self->stack, boolean, -1);
+ return 0;
+ }
+
/* s contains x bytes of a little-endian integer. Return its value as a
* C int. Obscure: when x is 1 or 2, this is an unsigned little-endian
***************
*** 4145,4148 ****
--- 4158,4171 ----
continue;
+ case NEWTRUE:
+ if (load_bool(self, Py_True) < 0)
+ break;
+ continue;
+
+ case NEWFALSE:
+ if (load_bool(self, Py_False) < 0)
+ break;
+ continue;
+
case '\0':
/* end of file */
***************
*** 4463,4466 ****
--- 4486,4498 ----
continue;
+ case NEWTRUE:
+ if (load_bool(self, Py_True) < 0)
+ break;
+ continue;
+
+ case NEWFALSE:
+ if (load_bool(self, Py_False) < 0)
+ break;
+ continue;
default:
cPickle_ErrFormat(UnpicklingError,