@@ -92,14 +92,13 @@ static PyObject *BadPickleGet;
9292
9393
9494static PyObject * dispatch_table ;
95- static PyObject * safe_constructors ;
9695static PyObject * empty_tuple ;
9796
9897static PyObject * __class___str , * __getinitargs___str , * __dict___str ,
9998 * __getstate___str , * __setstate___str , * __name___str , * __reduce___str ,
100- * write_str , * __safe_for_unpickling___str , * append_str ,
99+ * write_str , * append_str ,
101100 * read_str , * readline_str , * __main___str , * __basicnew___str ,
102- * copy_reg_str , * dispatch_table_str , * safe_constructors_str ;
101+ * copy_reg_str , * dispatch_table_str ;
103102
104103/*************************************************************************
105104 Internal Data type for pickle data. */
@@ -306,7 +305,6 @@ typedef struct Unpicklerobject {
306305 int (* readline_func )(struct Unpicklerobject * , char * * );
307306 int buf_size ;
308307 char * buf ;
309- PyObject * safe_constructors ;
310308 PyObject * find_class ;
311309} Unpicklerobject ;
312310
@@ -3078,8 +3076,7 @@ load_dict(Unpicklerobject *self)
30783076static PyObject *
30793077Instance_New (PyObject * cls , PyObject * args )
30803078{
3081- int has_key ;
3082- PyObject * safe = 0 , * r = 0 ;
3079+ PyObject * r = 0 ;
30833080
30843081 if (PyClass_Check (cls )) {
30853082 int l ;
@@ -3107,21 +3104,6 @@ Instance_New(PyObject *cls, PyObject *args)
31073104 else goto err ;
31083105 }
31093106
3110- /* Is safe_constructors always a dict? */
3111- has_key = cPickle_PyMapping_HasKey (safe_constructors , cls );
3112- if (!has_key ) {
3113- safe = PyObject_GetAttr (cls , __safe_for_unpickling___str );
3114- if (!safe ||
3115- !PyObject_IsTrue (safe )) {
3116- cPickle_ErrFormat (UnpicklingError ,
3117- "%s is not safe for unpickling" ,
3118- "O" , cls );
3119- Py_XDECREF (safe );
3120- return NULL ;
3121- }
3122- Py_DECREF (safe );
3123- }
3124-
31253107 if (args == Py_None ) {
31263108 /* Special case, call cls.__basicnew__() */
31273109 PyObject * basicnew ;
@@ -4332,7 +4314,6 @@ newUnpicklerobject(PyObject *f)
43324314 self -> buf_size = 0 ;
43334315 self -> read = NULL ;
43344316 self -> readline = NULL ;
4335- self -> safe_constructors = NULL ;
43364317 self -> find_class = NULL ;
43374318
43384319 if (!( self -> memo = PyDict_New ()))
@@ -4373,21 +4354,6 @@ newUnpicklerobject(PyObject *f)
43734354 }
43744355 }
43754356
4376- if (PyEval_GetRestricted ()) {
4377- /* Restricted execution, get private tables */
4378- PyObject * m ;
4379-
4380- if (!( m = PyImport_Import (copy_reg_str ))) goto err ;
4381- self -> safe_constructors = PyObject_GetAttr (m ,
4382- safe_constructors_str );
4383- Py_DECREF (m );
4384- if (!( self -> safe_constructors )) goto err ;
4385- }
4386- else {
4387- self -> safe_constructors = safe_constructors ;
4388- Py_INCREF (safe_constructors );
4389- }
4390-
43914357 return self ;
43924358
43934359 err :
@@ -4418,7 +4384,6 @@ Unpickler_dealloc(Unpicklerobject *self)
44184384 Py_XDECREF (self -> pers_func );
44194385 Py_XDECREF (self -> arg );
44204386 Py_XDECREF (self -> last_string );
4421- Py_XDECREF (self -> safe_constructors );
44224387
44234388 if (self -> marks ) {
44244389 free (self -> marks );
@@ -4693,28 +4658,22 @@ init_stuff(PyObject *module_dict)
46934658 INIT_STR (__main__ );
46944659 INIT_STR (__reduce__ );
46954660 INIT_STR (write );
4696- INIT_STR (__safe_for_unpickling__ );
46974661 INIT_STR (append );
46984662 INIT_STR (read );
46994663 INIT_STR (readline );
47004664 INIT_STR (copy_reg );
47014665 INIT_STR (dispatch_table );
4702- INIT_STR (safe_constructors );
47034666 INIT_STR (__basicnew__ );
47044667
47054668 if (!( copy_reg = PyImport_ImportModule ("copy_reg" )))
47064669 return -1 ;
47074670
4708- /* These next few are special because we want to use different
4709- ones in restricted mode. */
4671+ /* This is special because we want to use a different
4672+ one in restricted mode. */
47104673 dispatch_table = PyObject_GetAttr (copy_reg , dispatch_table_str );
47114674 if (!dispatch_table )
47124675 return -1 ;
47134676
4714- if (!( safe_constructors = PyObject_GetAttr (copy_reg ,
4715- safe_constructors_str )))
4716- return -1 ;
4717-
47184677 Py_DECREF (copy_reg );
47194678
47204679 /* Down to here ********************************** */
0 commit comments