11/*
2- * cPickle.c,v 1.67 1999/05/12 16 :09:45 jim Exp
2+ * cPickle.c,v 1.70 1999/06/15 14 :09:35 jim Exp
33 *
44 * Copyright (c) 1996-1998, Digital Creations, Fredericksburg, VA, USA.
55 * All rights reserved.
4949static char cPickle_module_documentation [] =
5050"C implementation and optimization of the Python pickle module\n"
5151"\n"
52- "cPickle.c,v 1.67 1999/05/12 16 :09:45 jim Exp\n"
52+ "cPickle.c,v 1.70 1999/06/15 14 :09:35 jim Exp\n"
5353;
5454
5555#include "Python.h"
@@ -599,7 +599,6 @@ readline_cStringIO(Unpicklerobject *self, char **s) {
599599static int
600600read_other (Unpicklerobject * self , char * * s , int n ) {
601601 PyObject * bytes , * str = 0 ;
602- int res = -1 ;
603602
604603 UNLESS (bytes = PyInt_FromLong (n )) return -1 ;
605604
@@ -2514,7 +2513,7 @@ load_float(Unpicklerobject *self) {
25142513static int
25152514load_binfloat (Unpicklerobject * self ) {
25162515 PyObject * py_float = 0 ;
2517- int s , e , res = -1 ;
2516+ int s , e ;
25182517 long fhi , flo ;
25192518 double x ;
25202519 char * p ;
@@ -2630,7 +2629,6 @@ static int
26302629load_binstring (Unpicklerobject * self ) {
26312630 PyObject * py_string = 0 ;
26322631 long l ;
2633- int res = -1 ;
26342632 char * s ;
26352633
26362634 if ((* self -> read_func )(self , & s , 4 ) < 0 ) return -1 ;
@@ -2652,7 +2650,6 @@ static int
26522650load_short_binstring (Unpicklerobject * self ) {
26532651 PyObject * py_string = 0 ;
26542652 unsigned char l ;
2655- int res = -1 ;
26562653 char * s ;
26572654
26582655 if ((* self -> read_func )(self , & s , 1 ) < 0 )
@@ -2840,7 +2837,7 @@ load_obj(Unpicklerobject *self) {
28402837
28412838static int
28422839load_inst (Unpicklerobject * self ) {
2843- PyObject * tup , * class , * obj , * module_name , * class_name ;
2840+ PyObject * tup , * class = 0 , * obj = 0 , * module_name , * class_name ;
28442841 int i , len ;
28452842 char * s ;
28462843
@@ -2852,7 +2849,7 @@ load_inst(Unpicklerobject *self) {
28522849
28532850 if ((len = (* self -> readline_func )(self , & s )) >= 0 ) {
28542851 if (len < 2 ) return bad_readline ();
2855- if (class_name = PyString_FromStringAndSize (s , len - 1 )) {
2852+ if (( class_name = PyString_FromStringAndSize (s , len - 1 ) )) {
28562853 class = find_class (module_name , class_name , self -> find_class );
28572854 Py_DECREF (class_name );
28582855 }
@@ -2861,7 +2858,7 @@ load_inst(Unpicklerobject *self) {
28612858
28622859 if (! class ) return -1 ;
28632860
2864- if (tup = Pdata_popTuple (self -> stack , i )) {
2861+ if (( tup = Pdata_popTuple (self -> stack , i ) )) {
28652862 obj = Instance_New (class , tup );
28662863 Py_DECREF (tup );
28672864 }
@@ -2886,7 +2883,7 @@ load_global(Unpicklerobject *self) {
28862883
28872884 if ((len = (* self -> readline_func )(self , & s )) >= 0 ) {
28882885 if (len < 2 ) return bad_readline ();
2889- if (class_name = PyString_FromStringAndSize (s , len - 1 )) {
2886+ if (( class_name = PyString_FromStringAndSize (s , len - 1 ) )) {
28902887 class = find_class (module_name , class_name , self -> find_class );
28912888 Py_DECREF (class_name );
28922889 }
@@ -2902,7 +2899,7 @@ load_global(Unpicklerobject *self) {
29022899static int
29032900load_persid (Unpicklerobject * self ) {
29042901 PyObject * pid = 0 ;
2905- int len , res = -1 ;
2902+ int len ;
29062903 char * s ;
29072904
29082905 if (self -> pers_func ) {
@@ -2941,7 +2938,6 @@ load_persid(Unpicklerobject *self) {
29412938static int
29422939load_binpersid (Unpicklerobject * self ) {
29432940 PyObject * pid = 0 ;
2944- int res = -1 ;
29452941
29462942 if (self -> pers_func ) {
29472943 PDATA_POP (self -> stack , pid );
@@ -3019,7 +3015,7 @@ load_dup(Unpicklerobject *self) {
30193015static int
30203016load_get (Unpicklerobject * self ) {
30213017 PyObject * py_str = 0 , * value = 0 ;
3022- int len , res = -1 ;
3018+ int len ;
30233019 char * s ;
30243020
30253021 if ((len = (* self -> readline_func )(self , & s )) < 0 ) return -1 ;
@@ -3043,7 +3039,6 @@ static int
30433039load_binget (Unpicklerobject * self ) {
30443040 PyObject * py_key = 0 , * value = 0 ;
30453041 unsigned char key ;
3046- int res = -1 ;
30473042 char * s ;
30483043
30493044 if ((* self -> read_func )(self , & s , 1 ) < 0 ) return -1 ;
@@ -3068,7 +3063,6 @@ load_long_binget(Unpicklerobject *self) {
30683063 PyObject * py_key = 0 , * value = 0 ;
30693064 unsigned char c , * s ;
30703065 long key ;
3071- int res = -1 ;
30723066
30733067 if ((* self -> read_func )(self , & s , 4 ) < 0 ) return -1 ;
30743068
@@ -3136,7 +3130,7 @@ load_long_binput(Unpicklerobject *self) {
31363130 PyObject * py_key = 0 , * value = 0 ;
31373131 long key ;
31383132 unsigned char c , * s ;
3139- int len , res = -1 ;
3133+ int len ;
31403134
31413135 if ((* self -> read_func )(self , & s , 4 ) < 0 ) return -1 ;
31423136 UNLESS (len = self -> stack -> length ) return stackUnderflow ();
@@ -3343,7 +3337,7 @@ load_reduce(Unpicklerobject *self) {
33433337
33443338static PyObject *
33453339load (Unpicklerobject * self ) {
3346- PyObject * stack = 0 , * err = 0 , * val = 0 ;
3340+ PyObject * err = 0 , * val = 0 ;
33473341 char * s ;
33483342
33493343 self -> num_marks = 0 ;
@@ -3623,7 +3617,7 @@ noload_build(Unpicklerobject *self) {
36233617
36243618static PyObject *
36253619noload (Unpicklerobject * self ) {
3626- PyObject * stack = 0 , * err = 0 , * val = 0 ;
3620+ PyObject * err = 0 , * val = 0 ;
36273621 char * s ;
36283622
36293623 self -> num_marks = 0 ;
@@ -4234,24 +4228,9 @@ static struct PyMethodDef cPickle_methods[] = {
42344228 { NULL , NULL }
42354229};
42364230
4237-
4238- #define CHECK_FOR_ERRORS (MESS ) \
4239- if (PyErr_Occurred()) { \
4240- PyObject *__sys_exc_type, *__sys_exc_value, *__sys_exc_traceback; \
4241- PyErr_Fetch( &__sys_exc_type, &__sys_exc_value, &__sys_exc_traceback); \
4242- fprintf(stderr, # MESS ":\n\t"); \
4243- PyObject_Print(__sys_exc_type, stderr,0); \
4244- fprintf(stderr,", "); \
4245- PyObject_Print(__sys_exc_value, stderr,0); \
4246- fprintf(stderr,"\n"); \
4247- fflush(stderr); \
4248- Py_FatalError(# MESS); \
4249- }
4250-
4251-
42524231static int
42534232init_stuff (PyObject * module , PyObject * module_dict ) {
4254- PyObject * string , * copy_reg , * t ;
4233+ PyObject * string , * copy_reg , * t , * r ;
42554234
42564235#define INIT_STR (S ) UNLESS(S ## _str=PyString_FromString(#S)) return -1;
42574236
@@ -4308,12 +4287,13 @@ init_stuff(PyObject *module, PyObject *module_dict) {
43084287 return -1 ;
43094288
43104289 UNLESS (t = PyDict_New ()) return -1 ;
4311- if (PyRun_String ("def __init__(self, *args): self.args=args\n\n"
4312- "def __str__(self):\n"
4313- " return self.args and ('%s' % self.args[0]) or '???'\n" ,
4314- Py_file_input ,
4315- module_dict , t )
4316- < 0 ) return -1 ;
4290+ UNLESS (r = PyRun_String (
4291+ "def __init__(self, *args): self.args=args\n\n"
4292+ "def __str__(self):\n"
4293+ " return self.args and ('%s' % self.args[0]) or '(what)'\n" ,
4294+ Py_file_input ,
4295+ module_dict , t ) ) return -1 ;
4296+ Py_DECREF (r );
43174297
43184298 UNLESS (PickleError = PyErr_NewException ("cPickle.PickleError" , NULL , t ))
43194299 return -1 ;
@@ -4326,14 +4306,15 @@ init_stuff(PyObject *module, PyObject *module_dict) {
43264306 return -1 ;
43274307
43284308 UNLESS (t = PyDict_New ()) return -1 ;
4329- if (PyRun_String ("def __init__(self, *args): self.args=args\n\n"
4330- "def __str__(self):\n"
4331- " a=self.args\n"
4332- " a=a and type(a[0]) or '(what)'\n"
4333- " return 'Cannot pickle %s objects' % a\n"
4334- , Py_file_input ,
4335- module_dict , t )
4336- < 0 ) return -1 ;
4309+ UNLESS (r = PyRun_String (
4310+ "def __init__(self, *args): self.args=args\n\n"
4311+ "def __str__(self):\n"
4312+ " a=self.args\n"
4313+ " a=a and type(a[0]) or '(what)'\n"
4314+ " return 'Cannot pickle %s objects' % a\n"
4315+ , Py_file_input ,
4316+ module_dict , t ) ) return -1 ;
4317+ Py_DECREF (r );
43374318
43384319 UNLESS (UnpickleableError = PyErr_NewException (
43394320 "cPickle.UnpickleableError" , PicklingError , t ))
@@ -4379,7 +4360,7 @@ init_stuff(PyObject *module, PyObject *module_dict) {
43794360DL_EXPORT (void )
43804361initcPickle () {
43814362 PyObject * m , * d , * v ;
4382- char * rev = "1.67 " ;
4363+ char * rev = "1.70 " ;
43834364 PyObject * format_version ;
43844365 PyObject * compatible_formats ;
43854366
@@ -4406,5 +4387,4 @@ initcPickle() {
44064387 Py_XDECREF (compatible_formats );
44074388
44084389 init_stuff (m , d );
4409- CHECK_FOR_ERRORS ("can't initialize module cPickle" );
44104390}
0 commit comments