Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
2f6ef4c6
Commit
2f6ef4c6
authored
Apr 01, 2002
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reindent. Break long lines. Move comments before the statements.
parent
4baedc1d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3642 additions
and
3483 deletions
+3642
-3483
Modules/cPickle.c
Modules/cPickle.c
+3642
-3483
No files found.
Modules/cPickle.c
View file @
2f6ef4c6
...
...
@@ -155,7 +155,8 @@ typedef struct {
}
Pdata
;
static
void
Pdata_dealloc
(
Pdata
*
self
)
{
Pdata_dealloc
(
Pdata
*
self
)
{
int
i
;
PyObject
**
p
;
...
...
@@ -175,7 +176,8 @@ static PyTypeObject PdataType = {
#define Pdata_Check(O) ((O)->ob_type == &PdataType)
static
PyObject
*
Pdata_New
(
void
)
{
Pdata_New
(
void
)
{
Pdata
*
self
;
if
(
!
(
self
=
PyObject_New
(
Pdata
,
&
PdataType
)))
return
NULL
;
...
...
@@ -188,13 +190,15 @@ Pdata_New(void) {
}
static
int
stackUnderflow
(
void
)
{
stackUnderflow
(
void
)
{
PyErr_SetString
(
UnpicklingError
,
"unpickling stack underflow"
);
return
-
1
;
}
static
int
Pdata_clear
(
Pdata
*
self
,
int
clearto
)
{
Pdata_clear
(
Pdata
*
self
,
int
clearto
)
{
int
i
;
PyObject
**
p
;
...
...
@@ -210,7 +214,8 @@ Pdata_clear(Pdata *self, int clearto) {
static
int
Pdata_grow
(
Pdata
*
self
)
{
Pdata_grow
(
Pdata
*
self
)
{
if
(
!
self
->
size
)
{
PyErr_NoMemory
();
return
-
1
;
...
...
@@ -235,7 +240,8 @@ Pdata_grow(Pdata *self) {
static
PyObject
*
Pdata_popTuple
(
Pdata
*
self
,
int
start
)
{
Pdata_popTuple
(
Pdata
*
self
,
int
start
)
{
PyObject
*
r
;
int
i
,
j
,
l
;
...
...
@@ -249,7 +255,8 @@ Pdata_popTuple(Pdata *self, int start) {
}
static
PyObject
*
Pdata_popList
(
Pdata
*
self
,
int
start
)
{
Pdata_popList
(
Pdata
*
self
,
int
start
)
{
PyObject
*
r
;
int
i
,
j
,
l
;
...
...
@@ -357,7 +364,8 @@ static int save(Picklerobject *, PyObject *, int);
static
int
put2
(
Picklerobject
*
,
PyObject
*
);
int
cPickle_PyMapping_HasKey
(
PyObject
*
o
,
PyObject
*
key
)
{
cPickle_PyMapping_HasKey
(
PyObject
*
o
,
PyObject
*
key
)
{
PyObject
*
v
;
if
((
v
=
PyObject_GetItem
(
o
,
key
)))
{
...
...
@@ -380,7 +388,8 @@ cPickle_ErrFormat(PyObject *ErrType, char *stringformat, char *format, ...)
if
(
format
)
args
=
Py_VaBuildValue
(
format
,
va
);
va_end
(
va
);
if
(
format
&&
!
args
)
return
NULL
;
if
(
stringformat
&&
!
(
retval
=
PyString_FromString
(
stringformat
)))
return
NULL
;
if
(
stringformat
&&
!
(
retval
=
PyString_FromString
(
stringformat
)))
return
NULL
;
if
(
retval
)
{
if
(
args
)
{
...
...
@@ -404,7 +413,8 @@ cPickle_ErrFormat(PyObject *ErrType, char *stringformat, char *format, ...)
}
static
int
write_file
(
Picklerobject
*
self
,
char
*
s
,
int
n
)
{
write_file
(
Picklerobject
*
self
,
char
*
s
,
int
n
)
{
size_t
nbyteswritten
;
if
(
s
==
NULL
)
{
...
...
@@ -423,7 +433,8 @@ write_file(Picklerobject *self, char *s, int n) {
}
static
int
write_cStringIO
(
Picklerobject
*
self
,
char
*
s
,
int
n
)
{
write_cStringIO
(
Picklerobject
*
self
,
char
*
s
,
int
n
)
{
if
(
s
==
NULL
)
{
return
0
;
}
...
...
@@ -436,19 +447,22 @@ write_cStringIO(Picklerobject *self, char *s, int n) {
}
static
int
write_none
(
Picklerobject
*
self
,
char
*
s
,
int
n
)
{
write_none
(
Picklerobject
*
self
,
char
*
s
,
int
n
)
{
if
(
s
==
NULL
)
return
0
;
return
n
;
}
static
int
write_other
(
Picklerobject
*
self
,
char
*
s
,
int
n
)
{
write_other
(
Picklerobject
*
self
,
char
*
s
,
int
n
)
{
PyObject
*
py_str
=
0
,
*
junk
=
0
;
if
(
s
==
NULL
)
{
if
(
!
(
self
->
buf_size
))
return
0
;
if
(
!
(
py_str
=
PyString_FromStringAndSize
(
self
->
write_buf
,
self
->
buf_size
)))
py_str
=
PyString_FromStringAndSize
(
self
->
write_buf
,
self
->
buf_size
);
if
(
!
py_str
)
return
-
1
;
}
else
{
...
...
@@ -488,7 +502,8 @@ write_other(Picklerobject *self, char *s, int n) {
static
int
read_file
(
Unpicklerobject
*
self
,
char
**
s
,
int
n
)
{
read_file
(
Unpicklerobject
*
self
,
char
**
s
,
int
n
)
{
size_t
nbytesread
;
if
(
self
->
buf_size
==
0
)
{
...
...
@@ -503,7 +518,8 @@ read_file(Unpicklerobject *self, char **s, int n) {
self
->
buf_size
=
size
;
}
else
if
(
n
>
self
->
buf_size
)
{
if
(
!
(
self
->
buf
=
(
char
*
)
realloc
(
self
->
buf
,
n
*
sizeof
(
char
))))
{
self
->
buf
=
(
char
*
)
realloc
(
self
->
buf
,
n
*
sizeof
(
char
));
if
(
!
self
->
buf
)
{
PyErr_NoMemory
();
return
-
1
;
}
...
...
@@ -531,7 +547,8 @@ read_file(Unpicklerobject *self, char **s, int n) {
static
int
readline_file
(
Unpicklerobject
*
self
,
char
**
s
)
{
readline_file
(
Unpicklerobject
*
self
,
char
**
s
)
{
int
i
;
if
(
self
->
buf_size
==
0
)
{
...
...
@@ -546,27 +563,28 @@ readline_file(Unpicklerobject *self, char **s) {
i
=
0
;
while
(
1
)
{
for
(;
i
<
(
self
->
buf_size
-
1
);
i
++
)
{
if
(
feof
(
self
->
fp
)
||
(
self
->
buf
[
i
]
=
getc
(
self
->
fp
))
==
'\n'
)
{
if
(
feof
(
self
->
fp
)
||
(
self
->
buf
[
i
]
=
getc
(
self
->
fp
))
==
'\n'
)
{
self
->
buf
[
i
+
1
]
=
'\0'
;
*
s
=
self
->
buf
;
return
i
+
1
;
}
}
if
(
!
(
self
->
buf
=
(
char
*
)
realloc
(
self
->
buf
,
(
self
->
buf_size
*
2
)
*
sizeof
(
char
)))
)
{
self
->
buf
=
(
char
*
)
realloc
(
self
->
buf
,
(
self
->
buf_size
*
2
)
*
sizeof
(
char
));
if
(
!
self
->
buf
)
{
PyErr_NoMemory
();
return
-
1
;
}
self
->
buf_size
*=
2
;
}
}
static
int
read_cStringIO
(
Unpicklerobject
*
self
,
char
**
s
,
int
n
)
{
read_cStringIO
(
Unpicklerobject
*
self
,
char
**
s
,
int
n
)
{
char
*
ptr
;
if
(
PycStringIO
->
cread
((
PyObject
*
)
self
->
file
,
&
ptr
,
n
)
!=
n
)
{
...
...
@@ -581,7 +599,8 @@ read_cStringIO(Unpicklerobject *self, char **s, int n) {
static
int
readline_cStringIO
(
Unpicklerobject
*
self
,
char
**
s
)
{
readline_cStringIO
(
Unpicklerobject
*
self
,
char
**
s
)
{
int
n
;
char
*
ptr
;
...
...
@@ -596,7 +615,8 @@ readline_cStringIO(Unpicklerobject *self, char **s) {
static
int
read_other
(
Unpicklerobject
*
self
,
char
**
s
,
int
n
)
{
read_other
(
Unpicklerobject
*
self
,
char
**
s
,
int
n
)
{
PyObject
*
bytes
,
*
str
=
0
;
if
(
!
(
bytes
=
PyInt_FromLong
(
n
)))
return
-
1
;
...
...
@@ -617,7 +637,8 @@ read_other(Unpicklerobject *self, char **s, int n) {
static
int
readline_other
(
Unpicklerobject
*
self
,
char
**
s
)
{
readline_other
(
Unpicklerobject
*
self
,
char
**
s
)
{
PyObject
*
str
;
int
str_size
;
...
...
@@ -639,7 +660,8 @@ readline_other(Unpicklerobject *self, char **s) {
static
char
*
pystrndup
(
char
*
s
,
int
l
)
{
pystrndup
(
char
*
s
,
int
l
)
{
char
*
r
;
if
(
!
(
r
=
malloc
((
l
+
1
)
*
sizeof
(
char
))))
return
(
char
*
)
PyErr_NoMemory
();
memcpy
(
r
,
s
,
l
);
...
...
@@ -649,7 +671,8 @@ pystrndup(char *s, int l) {
static
int
get
(
Picklerobject
*
self
,
PyObject
*
id
)
{
get
(
Picklerobject
*
self
,
PyObject
*
id
)
{
PyObject
*
value
,
*
mv
;
long
c_value
;
char
s
[
30
];
...
...
@@ -703,7 +726,8 @@ get(Picklerobject *self, PyObject *id) {
static
int
put
(
Picklerobject
*
self
,
PyObject
*
ob
)
{
put
(
Picklerobject
*
self
,
PyObject
*
ob
)
{
if
(
ob
->
ob_refcnt
<
2
||
self
->
fast
)
return
0
;
...
...
@@ -712,7 +736,8 @@ put(Picklerobject *self, PyObject *ob) {
static
int
put2
(
Picklerobject
*
self
,
PyObject
*
ob
)
{
put2
(
Picklerobject
*
self
,
PyObject
*
ob
)
{
char
c_str
[
30
];
int
p
;
size_t
len
;
...
...
@@ -725,7 +750,8 @@ put2(Picklerobject *self, PyObject *ob) {
if
((
p
=
PyDict_Size
(
self
->
memo
))
<
0
)
goto
finally
;
p
++
;
/* Make sure memo keys are positive! */
/* Make sure memo keys are positive! */
p
++
;
if
(
!
(
py_ob_id
=
PyLong_FromVoidPtr
(
ob
)))
goto
finally
;
...
...
@@ -776,7 +802,7 @@ put2(Picklerobject *self, PyObject *ob) {
res
=
0
;
finally:
finally:
Py_XDECREF
(
py_ob_id
);
Py_XDECREF
(
memo_len
);
Py_XDECREF
(
t
);
...
...
@@ -787,7 +813,8 @@ finally:
#define PyImport_Import cPickle_Import
static
PyObject
*
PyImport_Import
(
PyObject
*
module_name
)
{
PyImport_Import
(
PyObject
*
module_name
)
{
static
PyObject
*
silly_list
=
0
,
*
__builtins___str
=
0
,
*
__import___str
;
static
PyObject
*
standard_builtins
=
0
;
PyObject
*
globals
=
0
,
*
__import__
=
0
,
*
__builtins__
=
0
,
*
r
=
0
;
...
...
@@ -803,31 +830,36 @@ PyImport_Import(PyObject *module_name) {
if
((
globals
=
PyEval_GetGlobals
()))
{
Py_INCREF
(
globals
);
if
(
!
(
__builtins__
=
PyObject_GetItem
(
globals
,
__builtins___str
)))
__builtins__
=
PyObject_GetItem
(
globals
,
__builtins___str
);
if
(
!
__builtins__
)
goto
err
;
}
else
{
PyErr_Clear
();
if
(
!
(
standard_builtins
||
if
(
!
(
standard_builtins
||
(
standard_builtins
=
PyImport_ImportModule
(
"__builtin__"
))))
return
NULL
;
__builtins__
=
standard_builtins
;
Py_INCREF
(
__builtins__
);
if
(
!
(
globals
=
Py_BuildValue
(
"{sO}"
,
"__builtins__"
,
__builtins__
)))
globals
=
Py_BuildValue
(
"{sO}"
,
"__builtins__"
,
__builtins__
);
if
(
!
globals
)
goto
err
;
}
if
(
PyDict_Check
(
__builtins__
))
{
if
(
!
(
__import__
=
PyObject_GetItem
(
__builtins__
,
__import___str
)))
goto
err
;
__import__
=
PyObject_GetItem
(
__builtins__
,
__import___str
);
if
(
!
__import__
)
goto
err
;
}
else
{
if
(
!
(
__import__
=
PyObject_GetAttr
(
__builtins__
,
__import___str
)))
goto
err
;
__import__
=
PyObject_GetAttr
(
__builtins__
,
__import___str
);
if
(
!
__import__
)
goto
err
;
}
if
(
!
(
r
=
PyObject_CallFunction
(
__import__
,
"OOOO"
,
module_name
,
globals
,
globals
,
silly_list
)))
r
=
PyObject_CallFunction
(
__import__
,
"OOOO"
,
module_name
,
globals
,
globals
,
silly_list
);
if
(
!
r
)
goto
err
;
Py_DECREF
(
globals
);
...
...
@@ -835,7 +867,7 @@ PyImport_Import(PyObject *module_name) {
Py_DECREF
(
__import__
);
return
r
;
err:
err:
Py_XDECREF
(
globals
);
Py_XDECREF
(
__builtins__
);
Py_XDECREF
(
__import__
);
...
...
@@ -843,7 +875,8 @@ err:
}
static
PyObject
*
whichmodule
(
PyObject
*
global
,
PyObject
*
global_name
)
{
whichmodule
(
PyObject
*
global
,
PyObject
*
global_name
)
{
int
i
,
j
;
PyObject
*
module
=
0
,
*
modules_dict
=
0
,
*
global_name_attr
=
0
,
*
name
=
0
;
...
...
@@ -860,7 +893,8 @@ whichmodule(PyObject *global, PyObject *global_name) {
if
(
PyObject_Compare
(
name
,
__main___str
)
==
0
)
continue
;
if
(
!
(
global_name_attr
=
PyObject_GetAttr
(
module
,
global_name
)))
{
global_name_attr
=
PyObject_GetAttr
(
module
,
global_name
);
if
(
!
global_name_attr
)
{
PyErr_Clear
();
continue
;
}
...
...
@@ -935,7 +969,8 @@ fast_save_leave(Picklerobject *self, PyObject *obj)
}
static
int
save_none
(
Picklerobject
*
self
,
PyObject
*
args
)
{
save_none
(
Picklerobject
*
self
,
PyObject
*
args
)
{
static
char
none
=
NONE
;
if
((
*
self
->
write_func
)(
self
,
&
none
,
1
)
<
0
)
return
-
1
;
...
...
@@ -945,7 +980,8 @@ save_none(Picklerobject *self, PyObject *args) {
static
int
save_int
(
Picklerobject
*
self
,
PyObject
*
args
)
{
save_int
(
Picklerobject
*
self
,
PyObject
*
args
)
{
char
c_str
[
32
];
long
l
=
PyInt_AS_LONG
((
PyIntObject
*
)
args
);
int
len
=
0
;
...
...
@@ -995,7 +1031,8 @@ save_int(Picklerobject *self, PyObject *args) {
static
int
save_long
(
Picklerobject
*
self
,
PyObject
*
args
)
{
save_long
(
Picklerobject
*
self
,
PyObject
*
args
)
{
int
size
,
res
=
-
1
;
PyObject
*
repr
=
0
;
...
...
@@ -1011,7 +1048,8 @@ save_long(Picklerobject *self, PyObject *args) {
goto
finally
;
if
((
*
self
->
write_func
)(
self
,
PyString_AS_STRING
((
PyStringObject
*
)
repr
),
size
)
<
0
)
PyString_AS_STRING
((
PyStringObject
*
)
repr
),
size
)
<
0
)
goto
finally
;
if
((
*
self
->
write_func
)(
self
,
"
\n
"
,
1
)
<
0
)
...
...
@@ -1019,7 +1057,7 @@ save_long(Picklerobject *self, PyObject *args) {
res
=
0
;
finally:
finally:
Py_XDECREF
(
repr
);
return
res
;
...
...
@@ -1027,7 +1065,8 @@ finally:
static
int
save_float
(
Picklerobject
*
self
,
PyObject
*
args
)
{
save_float
(
Picklerobject
*
self
,
PyObject
*
args
)
{
double
x
=
PyFloat_AS_DOUBLE
((
PyFloatObject
*
)
args
);
if
(
self
->
bin
)
{
...
...
@@ -1079,7 +1118,8 @@ save_float(Picklerobject *self, PyObject *args) {
f
-=
1
.
0
;
/* Get rid of leading 1 */
}
/* fhi receives the high 28 bits; flo the low 24 bits (== 52 bits) */
/* fhi receives the high 28 bits;
flo the low 24 bits (== 52 bits) */
f
*=
268435456
.
0
;
/* 2**28 */
fhi
=
(
long
)
floor
(
f
);
/* Truncate */
f
-=
(
double
)
fhi
;
...
...
@@ -1134,7 +1174,8 @@ save_float(Picklerobject *self, PyObject *args) {
static
int
save_string
(
Picklerobject
*
self
,
PyObject
*
args
,
int
doput
)
{
save_string
(
Picklerobject
*
self
,
PyObject
*
args
,
int
doput
)
{
int
size
,
len
;
PyObject
*
repr
=
0
;
...
...
@@ -1203,7 +1244,7 @@ save_string(Picklerobject *self, PyObject *args, int doput) {
return
0
;
err:
err:
Py_XDECREF
(
repr
);
return
-
1
;
}
...
...
@@ -1256,7 +1297,8 @@ modified_EncodeRawUnicodeEscape(const Py_UNICODE *s, int size)
static
int
save_unicode
(
Picklerobject
*
self
,
PyObject
*
args
,
int
doput
)
{
save_unicode
(
Picklerobject
*
self
,
PyObject
*
args
,
int
doput
)
{
int
size
,
len
;
PyObject
*
repr
=
0
;
...
...
@@ -1267,8 +1309,9 @@ save_unicode(Picklerobject *self, PyObject *args, int doput) {
char
*
repr_str
;
static
char
string
=
UNICODE
;
if
(
!
(
repr
=
modified_EncodeRawUnicodeEscape
(
PyUnicode_AS_UNICODE
(
args
),
PyUnicode_GET_SIZE
(
args
))))
repr
=
modified_EncodeRawUnicodeEscape
(
PyUnicode_AS_UNICODE
(
args
),
PyUnicode_GET_SIZE
(
args
));
if
(
!
repr
)
return
-
1
;
if
((
len
=
PyString_Size
(
repr
))
<
0
)
...
...
@@ -1310,7 +1353,8 @@ save_unicode(Picklerobject *self, PyObject *args, int doput) {
PDATA_APPEND
(
self
->
file
,
repr
,
-
1
);
}
else
{
if
((
*
self
->
write_func
)(
self
,
PyString_AS_STRING
(
repr
),
size
)
<
0
)
if
((
*
self
->
write_func
)(
self
,
PyString_AS_STRING
(
repr
),
size
)
<
0
)
goto
err
;
}
...
...
@@ -1323,7 +1367,7 @@ save_unicode(Picklerobject *self, PyObject *args, int doput) {
return
0
;
err:
err:
Py_XDECREF
(
repr
);
return
-
1
;
}
...
...
@@ -1331,7 +1375,8 @@ err:
static
int
save_tuple
(
Picklerobject
*
self
,
PyObject
*
args
)
{
save_tuple
(
Picklerobject
*
self
,
PyObject
*
args
)
{
PyObject
*
element
=
0
,
*
py_tuple_id
=
0
;
int
len
,
i
,
res
=
-
1
;
...
...
@@ -1388,14 +1433,15 @@ save_tuple(Picklerobject *self, PyObject *args) {
res
=
0
;
finally:
finally:
Py_XDECREF
(
py_tuple_id
);
return
res
;
}
static
int
save_empty_tuple
(
Picklerobject
*
self
,
PyObject
*
args
)
{
save_empty_tuple
(
Picklerobject
*
self
,
PyObject
*
args
)
{
static
char
tuple
=
EMPTY_TUPLE
;
return
(
*
self
->
write_func
)(
self
,
&
tuple
,
1
);
...
...
@@ -1403,7 +1449,8 @@ save_empty_tuple(Picklerobject *self, PyObject *args) {
static
int
save_list
(
Picklerobject
*
self
,
PyObject
*
args
)
{
save_list
(
Picklerobject
*
self
,
PyObject
*
args
)
{
PyObject
*
element
=
0
;
int
s_len
,
len
,
i
,
using_appends
,
res
=
-
1
;
char
s
[
3
];
...
...
@@ -1462,7 +1509,7 @@ save_list(Picklerobject *self, PyObject *args) {
res
=
0
;
finally:
finally:
if
(
self
->
fast
&&
!
fast_save_leave
(
self
,
args
))
res
=
-
1
;
...
...
@@ -1471,7 +1518,8 @@ finally:
static
int
save_dict
(
Picklerobject
*
self
,
PyObject
*
args
)
{
save_dict
(
Picklerobject
*
self
,
PyObject
*
args
)
{
PyObject
*
key
=
0
,
*
value
=
0
;
int
i
,
len
,
res
=
-
1
,
using_setitems
;
char
s
[
3
];
...
...
@@ -1531,7 +1579,7 @@ save_dict(Picklerobject *self, PyObject *args) {
res
=
0
;
finally:
finally:
if
(
self
->
fast
&&
!
fast_save_leave
(
self
,
args
))
res
=
-
1
;
...
...
@@ -1540,7 +1588,8 @@ finally:
static
int
save_inst
(
Picklerobject
*
self
,
PyObject
*
args
)
{
save_inst
(
Picklerobject
*
self
,
PyObject
*
args
)
{
PyObject
*
class
=
0
,
*
module
=
0
,
*
name
=
0
,
*
state
=
0
,
*
getinitargs_func
=
0
,
*
getstate_func
=
0
,
*
class_args
=
0
;
char
*
module_str
,
*
name_str
;
...
...
@@ -1626,7 +1675,8 @@ save_inst(Picklerobject *self, PyObject *args) {
}
if
((
getstate_func
=
PyObject_GetAttr
(
args
,
__getstate___str
)))
{
if
(
!
(
state
=
PyObject_Call
(
getstate_func
,
empty_tuple
,
NULL
)))
state
=
PyObject_Call
(
getstate_func
,
empty_tuple
,
NULL
);
if
(
!
state
)
goto
finally
;
}
else
{
...
...
@@ -1656,7 +1706,7 @@ save_inst(Picklerobject *self, PyObject *args) {
res
=
0
;
finally:
finally:
if
(
self
->
fast
&&
!
fast_save_leave
(
self
,
args
))
res
=
-
1
;
...
...
@@ -1672,7 +1722,8 @@ finally:
static
int
save_global
(
Picklerobject
*
self
,
PyObject
*
args
,
PyObject
*
name
)
{
save_global
(
Picklerobject
*
self
,
PyObject
*
args
,
PyObject
*
name
)
{
PyObject
*
global_name
=
0
,
*
module
=
0
,
*
mod
=
0
,
*
moddict
=
0
,
*
klass
=
0
;
char
*
name_str
,
*
module_str
;
int
module_size
,
name_size
,
res
=
-
1
;
...
...
@@ -1706,8 +1757,10 @@ save_global(Picklerobject *self, PyObject *args, PyObject *name) {
"OSS"
,
args
,
module
,
global_name
);
goto
finally
;
}
moddict
=
PyModule_GetDict
(
mod
);
/* borrowed ref */
klass
=
PyDict_GetItemString
(
moddict
,
name_str
);
/* borrowed ref */
/* borrowed ref */
moddict
=
PyModule_GetDict
(
mod
);
/* borrowed ref */
klass
=
PyDict_GetItemString
(
moddict
,
name_str
);
if
(
klass
==
NULL
)
{
cPickle_ErrFormat
(
PicklingError
,
"Can't pickle %s: it's not found as %s.%s"
,
...
...
@@ -1741,7 +1794,7 @@ save_global(Picklerobject *self, PyObject *args, PyObject *name) {
res
=
0
;
finally:
finally:
Py_XDECREF
(
module
);
Py_XDECREF
(
global_name
);
Py_XDECREF
(
mod
);
...
...
@@ -1750,7 +1803,8 @@ finally:
}
static
int
save_pers
(
Picklerobject
*
self
,
PyObject
*
args
,
PyObject
*
f
)
{
save_pers
(
Picklerobject
*
self
,
PyObject
*
args
,
PyObject
*
f
)
{
PyObject
*
pid
=
0
;
int
size
,
res
=
-
1
;
...
...
@@ -1800,7 +1854,7 @@ save_pers(Picklerobject *self, PyObject *args, PyObject *f) {
res
=
0
;
finally:
finally:
Py_XDECREF
(
pid
);
return
res
;
...
...
@@ -1809,7 +1863,8 @@ finally:
static
int
save_reduce
(
Picklerobject
*
self
,
PyObject
*
callable
,
PyObject
*
tup
,
PyObject
*
state
,
PyObject
*
ob
)
{
PyObject
*
tup
,
PyObject
*
state
,
PyObject
*
ob
)
{
static
char
reduce
=
REDUCE
,
build
=
BUILD
;
if
(
save
(
self
,
callable
,
0
)
<
0
)
...
...
@@ -1844,7 +1899,8 @@ save_reduce(Picklerobject *self, PyObject *callable,
}
static
int
save
(
Picklerobject
*
self
,
PyObject
*
args
,
int
pers_save
)
{
save
(
Picklerobject
*
self
,
PyObject
*
args
,
int
pers_save
)
{
PyTypeObject
*
type
;
PyObject
*
py_ob_id
=
0
,
*
__reduce__
=
0
,
*
t
=
0
,
*
arg_tup
=
0
,
*
callable
=
0
,
*
state
=
0
;
...
...
@@ -2019,7 +2075,8 @@ save(Picklerobject *self, PyObject *args, int pers_save) {
PyErr_Clear
();
if
((
__reduce__
=
PyObject_GetAttr
(
args
,
__reduce___str
)))
{
if
(
!
(
t
=
PyObject_Call
(
__reduce__
,
empty_tuple
,
NULL
)))
t
=
PyObject_Call
(
__reduce__
,
empty_tuple
,
NULL
);
if
(
!
t
)
goto
finally
;
}
else
{
...
...
@@ -2067,7 +2124,7 @@ save(Picklerobject *self, PyObject *args, int pers_save) {
PyErr_SetObject
(
UnpickleableError
,
args
);
finally:
finally:
Py_XDECREF
(
py_ob_id
);
Py_XDECREF
(
__reduce__
);
Py_XDECREF
(
t
);
...
...
@@ -2077,7 +2134,8 @@ finally:
static
int
dump
(
Picklerobject
*
self
,
PyObject
*
args
)
{
dump
(
Picklerobject
*
self
,
PyObject
*
args
)
{
static
char
stop
=
STOP
;
if
(
save
(
self
,
args
,
0
)
<
0
)
...
...
@@ -2093,7 +2151,8 @@ dump(Picklerobject *self, PyObject *args) {
}
static
PyObject
*
Pickle_clear_memo
(
Picklerobject
*
self
,
PyObject
*
args
)
{
Pickle_clear_memo
(
Picklerobject
*
self
,
PyObject
*
args
)
{
if
(
!
PyArg_ParseTuple
(
args
,
":clear_memo"
))
return
NULL
;
if
(
self
->
memo
)
...
...
@@ -2103,7 +2162,8 @@ Pickle_clear_memo(Picklerobject *self, PyObject *args) {
}
static
PyObject
*
Pickle_getvalue
(
Picklerobject
*
self
,
PyObject
*
args
)
{
Pickle_getvalue
(
Picklerobject
*
self
,
PyObject
*
args
)
{
int
l
,
i
,
rsize
,
ssize
,
clear
=
1
,
lm
;
long
ik
;
PyObject
*
k
,
*
r
;
...
...
@@ -2234,13 +2294,14 @@ Pickle_getvalue(Picklerobject *self, PyObject *args) {
free
(
have_get
);
return
r
;
err:
err:
free
(
have_get
);
return
NULL
;
}
static
PyObject
*
Pickler_dump
(
Picklerobject
*
self
,
PyObject
*
args
)
{
Pickler_dump
(
Picklerobject
*
self
,
PyObject
*
args
)
{
PyObject
*
ob
;
int
get
=
0
;
...
...
@@ -2258,7 +2319,8 @@ Pickler_dump(Picklerobject *self, PyObject *args) {
}
static
struct
PyMethodDef
Pickler_methods
[]
=
{
static
struct
PyMethodDef
Pickler_methods
[]
=
{
{
"dump"
,
(
PyCFunction
)
Pickler_dump
,
METH_VARARGS
,
"dump(object) --"
"Write an object in pickle format to the object's pickle stream
\n
"
...
...
@@ -2272,7 +2334,8 @@ static struct PyMethodDef Pickler_methods[] = {
static
Picklerobject
*
newPicklerobject
(
PyObject
*
file
,
int
bin
)
{
newPicklerobject
(
PyObject
*
file
,
int
bin
)
{
Picklerobject
*
self
;
if
(
!
(
self
=
PyObject_New
(
Picklerobject
,
&
Picklertype
)))
...
...
@@ -2321,9 +2384,11 @@ newPicklerobject(PyObject *file, int bin) {
self
->
write_func
=
write_other
;
if
(
!
Pdata_Check
(
file
))
{
if
(
!
(
self
->
write
=
PyObject_GetAttr
(
file
,
write_str
)))
{
self
->
write
=
PyObject_GetAttr
(
file
,
write_str
);
if
(
!
self
->
write
)
{
PyErr_Clear
();
PyErr_SetString
(
PyExc_TypeError
,
"argument must have 'write' "
PyErr_SetString
(
PyExc_TypeError
,
"argument must have 'write' "
"attribute"
);
goto
err
;
}
...
...
@@ -2352,14 +2417,15 @@ newPicklerobject(PyObject *file, int bin) {
return
self
;
err:
err:
Py_DECREF
((
PyObject
*
)
self
);
return
NULL
;
}
static
PyObject
*
get_Pickler
(
PyObject
*
self
,
PyObject
*
args
)
{
get_Pickler
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
file
=
NULL
;
int
bin
=
1
;
...
...
@@ -2374,7 +2440,8 @@ get_Pickler(PyObject *self, PyObject *args) {
static
void
Pickler_dealloc
(
Picklerobject
*
self
)
{
Pickler_dealloc
(
Picklerobject
*
self
)
{
Py_XDECREF
(
self
->
write
);
Py_XDECREF
(
self
->
memo
);
Py_XDECREF
(
self
->
fast_memo
);
...
...
@@ -2518,7 +2585,8 @@ static PyTypeObject Picklertype = {
};
static
PyObject
*
find_class
(
PyObject
*
py_module_name
,
PyObject
*
py_global_name
,
PyObject
*
fc
)
{
find_class
(
PyObject
*
py_module_name
,
PyObject
*
py_global_name
,
PyObject
*
fc
)
{
PyObject
*
global
=
0
,
*
module
;
if
(
fc
)
{
...
...
@@ -2527,7 +2595,8 @@ find_class(PyObject *py_module_name, PyObject *py_global_name, PyObject *fc) {
"Global and instance pickles are not supported."
);
return
NULL
;
}
return
PyObject_CallFunction
(
fc
,
"OO"
,
py_module_name
,
py_global_name
);
return
PyObject_CallFunction
(
fc
,
"OO"
,
py_module_name
,
py_global_name
);
}
module
=
PySys_GetObject
(
"modules"
);
...
...
@@ -2548,7 +2617,8 @@ find_class(PyObject *py_module_name, PyObject *py_global_name, PyObject *fc) {
}
static
int
marker
(
Unpicklerobject
*
self
)
{
marker
(
Unpicklerobject
*
self
)
{
if
(
self
->
num_marks
<
1
)
{
PyErr_SetString
(
UnpicklingError
,
"could not find MARK"
);
return
-
1
;
...
...
@@ -2559,19 +2629,22 @@ marker(Unpicklerobject *self) {
static
int
load_none
(
Unpicklerobject
*
self
)
{
load_none
(
Unpicklerobject
*
self
)
{
PDATA_APPEND
(
self
->
stack
,
Py_None
,
-
1
);
return
0
;
}
static
int
bad_readline
(
void
)
{
bad_readline
(
void
)
{
PyErr_SetString
(
UnpicklingError
,
"pickle data was truncated"
);
return
-
1
;
}
static
int
load_int
(
Unpicklerobject
*
self
)
{
load_int
(
Unpicklerobject
*
self
)
{
PyObject
*
py_int
=
0
;
char
*
endptr
,
*
s
;
int
len
,
res
=
-
1
;
...
...
@@ -2603,7 +2676,7 @@ load_int(Unpicklerobject *self) {
PDATA_PUSH
(
self
->
stack
,
py_int
,
-
1
);
return
0
;
finally:
finally:
free
(
s
);
return
res
;
...
...
@@ -2611,7 +2684,8 @@ finally:
static
long
calc_binint
(
char
*
s
,
int
x
)
{
calc_binint
(
char
*
s
,
int
x
)
{
unsigned
char
c
;
int
i
;
long
l
;
...
...
@@ -2633,7 +2707,8 @@ calc_binint(char *s, int x) {
static
int
load_binintx
(
Unpicklerobject
*
self
,
char
*
s
,
int
x
)
{
load_binintx
(
Unpicklerobject
*
self
,
char
*
s
,
int
x
)
{
PyObject
*
py_int
=
0
;
long
l
;
...
...
@@ -2648,7 +2723,8 @@ load_binintx(Unpicklerobject *self, char *s, int x) {
static
int
load_binint
(
Unpicklerobject
*
self
)
{
load_binint
(
Unpicklerobject
*
self
)
{
char
*
s
;
if
((
*
self
->
read_func
)(
self
,
&
s
,
4
)
<
0
)
...
...
@@ -2659,7 +2735,8 @@ load_binint(Unpicklerobject *self) {
static
int
load_binint1
(
Unpicklerobject
*
self
)
{
load_binint1
(
Unpicklerobject
*
self
)
{
char
*
s
;
if
((
*
self
->
read_func
)(
self
,
&
s
,
1
)
<
0
)
...
...
@@ -2670,7 +2747,8 @@ load_binint1(Unpicklerobject *self) {
static
int
load_binint2
(
Unpicklerobject
*
self
)
{
load_binint2
(
Unpicklerobject
*
self
)
{
char
*
s
;
if
((
*
self
->
read_func
)(
self
,
&
s
,
2
)
<
0
)
...
...
@@ -2680,7 +2758,8 @@ load_binint2(Unpicklerobject *self) {
}
static
int
load_long
(
Unpicklerobject
*
self
)
{
load_long
(
Unpicklerobject
*
self
)
{
PyObject
*
l
=
0
;
char
*
end
,
*
s
;
int
len
,
res
=
-
1
;
...
...
@@ -2696,7 +2775,7 @@ load_long(Unpicklerobject *self) {
PDATA_PUSH
(
self
->
stack
,
l
,
-
1
);
return
0
;
finally:
finally:
free
(
s
);
return
res
;
...
...
@@ -2704,7 +2783,8 @@ finally:
static
int
load_float
(
Unpicklerobject
*
self
)
{
load_float
(
Unpicklerobject
*
self
)
{
PyObject
*
py_float
=
0
;
char
*
endptr
,
*
s
;
int
len
,
res
=
-
1
;
...
...
@@ -2730,14 +2810,15 @@ load_float(Unpicklerobject *self) {
PDATA_PUSH
(
self
->
stack
,
py_float
,
-
1
);
return
0
;
finally:
finally:
free
(
s
);
return
res
;
}
static
int
load_binfloat
(
Unpicklerobject
*
self
)
{
load_binfloat
(
Unpicklerobject
*
self
)
{
PyObject
*
py_float
=
0
;
int
s
,
e
;
long
fhi
,
flo
;
...
...
@@ -2802,7 +2883,8 @@ load_binfloat(Unpicklerobject *self) {
}
static
int
load_string
(
Unpicklerobject
*
self
)
{
load_string
(
Unpicklerobject
*
self
)
{
PyObject
*
str
=
0
;
int
len
,
res
=
-
1
,
nslash
;
char
*
s
,
q
,
*
p
;
...
...
@@ -2841,12 +2923,12 @@ load_string(Unpicklerobject *self) {
PDATA_PUSH
(
self
->
stack
,
str
,
-
1
);
return
0
;
finally:
finally:
free
(
s
);
return
res
;
insecure:
insecure:
free
(
s
);
PyErr_SetString
(
PyExc_ValueError
,
"insecure string pickle"
);
return
-
1
;
...
...
@@ -2854,7 +2936,8 @@ insecure:
static
int
load_binstring
(
Unpicklerobject
*
self
)
{
load_binstring
(
Unpicklerobject
*
self
)
{
PyObject
*
py_string
=
0
;
long
l
;
char
*
s
;
...
...
@@ -2875,7 +2958,8 @@ load_binstring(Unpicklerobject *self) {
static
int
load_short_binstring
(
Unpicklerobject
*
self
)
{
load_short_binstring
(
Unpicklerobject
*
self
)
{
PyObject
*
py_string
=
0
;
unsigned
char
l
;
char
*
s
;
...
...
@@ -2896,7 +2980,8 @@ load_short_binstring(Unpicklerobject *self) {
#ifdef Py_USING_UNICODE
static
int
load_unicode
(
Unpicklerobject
*
self
)
{
load_unicode
(
Unpicklerobject
*
self
)
{
PyObject
*
str
=
0
;
int
len
,
res
=
-
1
;
char
*
s
;
...
...
@@ -2910,7 +2995,7 @@ load_unicode(Unpicklerobject *self) {
PDATA_PUSH
(
self
->
stack
,
str
,
-
1
);
return
0
;
finally:
finally:
return
res
;
}
#endif
...
...
@@ -2918,7 +3003,8 @@ finally:
#ifdef Py_USING_UNICODE
static
int
load_binunicode
(
Unpicklerobject
*
self
)
{
load_binunicode
(
Unpicklerobject
*
self
)
{
PyObject
*
unicode
;
long
l
;
char
*
s
;
...
...
@@ -2940,7 +3026,8 @@ load_binunicode(Unpicklerobject *self) {
static
int
load_tuple
(
Unpicklerobject
*
self
)
{
load_tuple
(
Unpicklerobject
*
self
)
{
PyObject
*
tup
;
int
i
;
...
...
@@ -2951,7 +3038,8 @@ load_tuple(Unpicklerobject *self) {
}
static
int
load_empty_tuple
(
Unpicklerobject
*
self
)
{
load_empty_tuple
(
Unpicklerobject
*
self
)
{
PyObject
*
tup
;
if
(
!
(
tup
=
PyTuple_New
(
0
)))
return
-
1
;
...
...
@@ -2960,7 +3048,8 @@ load_empty_tuple(Unpicklerobject *self) {
}
static
int
load_empty_list
(
Unpicklerobject
*
self
)
{
load_empty_list
(
Unpicklerobject
*
self
)
{
PyObject
*
list
;
if
(
!
(
list
=
PyList_New
(
0
)))
return
-
1
;
...
...
@@ -2969,7 +3058,8 @@ load_empty_list(Unpicklerobject *self) {
}
static
int
load_empty_dict
(
Unpicklerobject
*
self
)
{
load_empty_dict
(
Unpicklerobject
*
self
)
{
PyObject
*
dict
;
if
(
!
(
dict
=
PyDict_New
()))
return
-
1
;
...
...
@@ -2979,7 +3069,8 @@ load_empty_dict(Unpicklerobject *self) {
static
int
load_list
(
Unpicklerobject
*
self
)
{
load_list
(
Unpicklerobject
*
self
)
{
PyObject
*
list
=
0
;
int
i
;
...
...
@@ -2990,7 +3081,8 @@ load_list(Unpicklerobject *self) {
}
static
int
load_dict
(
Unpicklerobject
*
self
)
{
load_dict
(
Unpicklerobject
*
self
)
{
PyObject
*
dict
,
*
key
,
*
value
;
int
i
,
j
,
k
;
...
...
@@ -3013,7 +3105,8 @@ load_dict(Unpicklerobject *self) {
}
static
PyObject
*
Instance_New
(
PyObject
*
cls
,
PyObject
*
args
)
{
Instance_New
(
PyObject
*
cls
,
PyObject
*
args
)
{
int
has_key
;
PyObject
*
safe
=
0
,
*
r
=
0
;
...
...
@@ -3024,9 +3117,11 @@ Instance_New(PyObject *cls, PyObject *args) {
if
(
!
(
l
))
{
PyObject
*
__getinitargs__
;
if
(
!
(
__getinitargs__
=
PyObject_GetAttr
(
cls
,
__getinitargs___str
)))
{
/* We have a class with no __getinitargs__, so bypass usual
construction */
__getinitargs__
=
PyObject_GetAttr
(
cls
,
__getinitargs___str
);
if
(
!
__getinitargs__
)
{
/* We have a class with no __getinitargs__,
so bypass usual construction */
PyObject
*
inst
;
PyErr_Clear
();
...
...
@@ -3043,20 +3138,24 @@ Instance_New(PyObject *cls, PyObject *args) {
/* Is safe_constructors always a dict? */
has_key
=
cPickle_PyMapping_HasKey
(
safe_constructors
,
cls
);
if
(
!
has_key
)
if
(
!
(
safe
=
PyObject_GetAttr
(
cls
,
__safe_for_unpickling___str
))
||
if
(
!
has_key
)
{
safe
=
PyObject_GetAttr
(
cls
,
__safe_for_unpickling___str
);
if
(
!
safe
||
!
PyObject_IsTrue
(
safe
))
{
cPickle_ErrFormat
(
UnpicklingError
,
"%s is not safe for unpickling"
,
"O"
,
cls
);
"%s is not safe for unpickling"
,
"O"
,
cls
);
Py_XDECREF
(
safe
);
return
NULL
;
}
}
if
(
args
==
Py_None
)
{
/* Special case, call cls.__basicnew__() */
PyObject
*
basicnew
;
if
(
!
(
basicnew
=
PyObject_GetAttr
(
cls
,
__basicnew___str
)))
return
NULL
;
basicnew
=
PyObject_GetAttr
(
cls
,
__basicnew___str
);
if
(
!
basicnew
)
return
NULL
;
r
=
PyObject_CallObject
(
basicnew
,
NULL
);
Py_DECREF
(
basicnew
);
if
(
r
)
return
r
;
...
...
@@ -3064,7 +3163,7 @@ Instance_New(PyObject *cls, PyObject *args) {
if
((
r
=
PyObject_CallObject
(
cls
,
args
)))
return
r
;
err:
err:
{
PyObject
*
tp
,
*
v
,
*
tb
;
...
...
@@ -3080,7 +3179,8 @@ err:
static
int
load_obj
(
Unpicklerobject
*
self
)
{
load_obj
(
Unpicklerobject
*
self
)
{
PyObject
*
class
,
*
tup
,
*
obj
=
0
;
int
i
;
...
...
@@ -3100,7 +3200,8 @@ load_obj(Unpicklerobject *self) {
static
int
load_inst
(
Unpicklerobject
*
self
)
{
load_inst
(
Unpicklerobject
*
self
)
{
PyObject
*
tup
,
*
class
=
0
,
*
obj
=
0
,
*
module_name
,
*
class_name
;
int
i
,
len
;
char
*
s
;
...
...
@@ -3109,12 +3210,14 @@ load_inst(Unpicklerobject *self) {
if
((
len
=
(
*
self
->
readline_func
)(
self
,
&
s
))
<
0
)
return
-
1
;
if
(
len
<
2
)
return
bad_readline
();
if
(
!
(
module_name
=
PyString_FromStringAndSize
(
s
,
len
-
1
)))
return
-
1
;
module_name
=
PyString_FromStringAndSize
(
s
,
len
-
1
);
if
(
!
module_name
)
return
-
1
;
if
((
len
=
(
*
self
->
readline_func
)(
self
,
&
s
))
>=
0
)
{
if
(
len
<
2
)
return
bad_readline
();
if
((
class_name
=
PyString_FromStringAndSize
(
s
,
len
-
1
)))
{
class
=
find_class
(
module_name
,
class_name
,
self
->
find_class
);
class
=
find_class
(
module_name
,
class_name
,
self
->
find_class
);
Py_DECREF
(
class_name
);
}
}
...
...
@@ -3136,19 +3239,22 @@ load_inst(Unpicklerobject *self) {
static
int
load_global
(
Unpicklerobject
*
self
)
{
load_global
(
Unpicklerobject
*
self
)
{
PyObject
*
class
=
0
,
*
module_name
=
0
,
*
class_name
=
0
;
int
len
;
char
*
s
;
if
((
len
=
(
*
self
->
readline_func
)(
self
,
&
s
))
<
0
)
return
-
1
;
if
(
len
<
2
)
return
bad_readline
();
if
(
!
(
module_name
=
PyString_FromStringAndSize
(
s
,
len
-
1
)))
return
-
1
;
module_name
=
PyString_FromStringAndSize
(
s
,
len
-
1
);
if
(
!
module_name
)
return
-
1
;
if
((
len
=
(
*
self
->
readline_func
)(
self
,
&
s
))
>=
0
)
{
if
(
len
<
2
)
return
bad_readline
();
if
((
class_name
=
PyString_FromStringAndSize
(
s
,
len
-
1
)))
{
class
=
find_class
(
module_name
,
class_name
,
self
->
find_class
);
class
=
find_class
(
module_name
,
class_name
,
self
->
find_class
);
Py_DECREF
(
class_name
);
}
}
...
...
@@ -3161,7 +3267,8 @@ load_global(Unpicklerobject *self) {
static
int
load_persid
(
Unpicklerobject
*
self
)
{
load_persid
(
Unpicklerobject
*
self
)
{
PyObject
*
pid
=
0
;
int
len
;
char
*
s
;
...
...
@@ -3170,7 +3277,8 @@ load_persid(Unpicklerobject *self) {
if
((
len
=
(
*
self
->
readline_func
)(
self
,
&
s
))
<
0
)
return
-
1
;
if
(
len
<
2
)
return
bad_readline
();
if
(
!
(
pid
=
PyString_FromStringAndSize
(
s
,
len
-
1
)))
return
-
1
;
pid
=
PyString_FromStringAndSize
(
s
,
len
-
1
);
if
(
!
pid
)
return
-
1
;
if
(
PyList_Check
(
self
->
pers_func
))
{
if
(
PyList_Append
(
self
->
pers_func
,
pid
)
<
0
)
{
...
...
@@ -3181,7 +3289,8 @@ load_persid(Unpicklerobject *self) {
else
{
ARG_TUP
(
self
,
pid
);
if
(
self
->
arg
)
{
pid
=
PyObject_Call
(
self
->
pers_func
,
self
->
arg
,
NULL
);
pid
=
PyObject_Call
(
self
->
pers_func
,
self
->
arg
,
NULL
);
FREE_ARG_TUP
(
self
);
}
}
...
...
@@ -3200,7 +3309,8 @@ load_persid(Unpicklerobject *self) {
}
static
int
load_binpersid
(
Unpicklerobject
*
self
)
{
load_binpersid
(
Unpicklerobject
*
self
)
{
PyObject
*
pid
=
0
;
if
(
self
->
pers_func
)
{
...
...
@@ -3216,7 +3326,8 @@ load_binpersid(Unpicklerobject *self) {
else
{
ARG_TUP
(
self
,
pid
);
if
(
self
->
arg
)
{
pid
=
PyObject_Call
(
self
->
pers_func
,
self
->
arg
,
NULL
);
pid
=
PyObject_Call
(
self
->
pers_func
,
self
->
arg
,
NULL
);
FREE_ARG_TUP
(
self
);
}
if
(
!
pid
)
return
-
1
;
...
...
@@ -3235,7 +3346,8 @@ load_binpersid(Unpicklerobject *self) {
static
int
load_pop
(
Unpicklerobject
*
self
)
{
load_pop
(
Unpicklerobject
*
self
)
{
int
len
;
if
(
!
(
(
len
=
self
->
stack
->
length
)
>
0
))
return
stackUnderflow
();
...
...
@@ -3260,7 +3372,8 @@ load_pop(Unpicklerobject *self) {
static
int
load_pop_mark
(
Unpicklerobject
*
self
)
{
load_pop_mark
(
Unpicklerobject
*
self
)
{
int
i
;
if
((
i
=
marker
(
self
))
<
0
)
...
...
@@ -3273,7 +3386,8 @@ load_pop_mark(Unpicklerobject *self) {
static
int
load_dup
(
Unpicklerobject
*
self
)
{
load_dup
(
Unpicklerobject
*
self
)
{
PyObject
*
last
;
int
len
;
...
...
@@ -3286,7 +3400,8 @@ load_dup(Unpicklerobject *self) {
static
int
load_get
(
Unpicklerobject
*
self
)
{
load_get
(
Unpicklerobject
*
self
)
{
PyObject
*
py_str
=
0
,
*
value
=
0
;
int
len
;
char
*
s
;
...
...
@@ -3312,7 +3427,8 @@ load_get(Unpicklerobject *self) {
static
int
load_binget
(
Unpicklerobject
*
self
)
{
load_binget
(
Unpicklerobject
*
self
)
{
PyObject
*
py_key
=
0
,
*
value
=
0
;
unsigned
char
key
;
char
*
s
;
...
...
@@ -3338,7 +3454,8 @@ load_binget(Unpicklerobject *self) {
static
int
load_long_binget
(
Unpicklerobject
*
self
)
{
load_long_binget
(
Unpicklerobject
*
self
)
{
PyObject
*
py_key
=
0
,
*
value
=
0
;
unsigned
char
c
;
char
*
s
;
...
...
@@ -3373,7 +3490,8 @@ load_long_binget(Unpicklerobject *self) {
static
int
load_put
(
Unpicklerobject
*
self
)
{
load_put
(
Unpicklerobject
*
self
)
{
PyObject
*
py_str
=
0
,
*
value
=
0
;
int
len
,
l
;
char
*
s
;
...
...
@@ -3390,7 +3508,8 @@ load_put(Unpicklerobject *self) {
static
int
load_binput
(
Unpicklerobject
*
self
)
{
load_binput
(
Unpicklerobject
*
self
)
{
PyObject
*
py_key
=
0
,
*
value
=
0
;
unsigned
char
key
;
char
*
s
;
...
...
@@ -3410,7 +3529,8 @@ load_binput(Unpicklerobject *self) {
static
int
load_long_binput
(
Unpicklerobject
*
self
)
{
load_long_binput
(
Unpicklerobject
*
self
)
{
PyObject
*
py_key
=
0
,
*
value
=
0
;
long
key
;
unsigned
char
c
;
...
...
@@ -3438,12 +3558,15 @@ load_long_binput(Unpicklerobject *self) {
static
int
do_append
(
Unpicklerobject
*
self
,
int
x
)
{
do_append
(
Unpicklerobject
*
self
,
int
x
)
{
PyObject
*
value
=
0
,
*
list
=
0
,
*
append_method
=
0
;
int
len
,
i
;
if
(
!
(
(
len
=
self
->
stack
->
length
)
>=
x
&&
x
>
0
))
return
stackUnderflow
();
if
(
len
==
x
)
return
0
;
/* nothing to do */
len
=
self
->
stack
->
length
;
if
(
!
(
len
>=
x
&&
x
>
0
))
return
stackUnderflow
();
/* nothing to do */
if
(
len
==
x
)
return
0
;
list
=
self
->
stack
->
data
[
x
-
1
];
...
...
@@ -3469,7 +3592,8 @@ do_append(Unpicklerobject *self, int x) {
junk
=
0
;
ARG_TUP
(
self
,
value
);
if
(
self
->
arg
)
{
junk
=
PyObject_Call
(
append_method
,
self
->
arg
,
NULL
);
junk
=
PyObject_Call
(
append_method
,
self
->
arg
,
NULL
);
FREE_ARG_TUP
(
self
);
}
if
(
!
junk
)
{
...
...
@@ -3489,19 +3613,22 @@ do_append(Unpicklerobject *self, int x) {
static
int
load_append
(
Unpicklerobject
*
self
)
{
load_append
(
Unpicklerobject
*
self
)
{
return
do_append
(
self
,
self
->
stack
->
length
-
1
);
}
static
int
load_appends
(
Unpicklerobject
*
self
)
{
load_appends
(
Unpicklerobject
*
self
)
{
return
do_append
(
self
,
marker
(
self
));
}
static
int
do_setitems
(
Unpicklerobject
*
self
,
int
x
)
{
do_setitems
(
Unpicklerobject
*
self
,
int
x
)
{
PyObject
*
value
=
0
,
*
key
=
0
,
*
dict
=
0
;
int
len
,
i
,
r
=
0
;
...
...
@@ -3526,18 +3653,21 @@ do_setitems(Unpicklerobject *self, int x) {
static
int
load_setitem
(
Unpicklerobject
*
self
)
{
load_setitem
(
Unpicklerobject
*
self
)
{
return
do_setitems
(
self
,
self
->
stack
->
length
-
2
);
}
static
int
load_setitems
(
Unpicklerobject
*
self
)
{
load_setitems
(
Unpicklerobject
*
self
)
{
return
do_setitems
(
self
,
marker
(
self
));
}
static
int
load_build
(
Unpicklerobject
*
self
)
{
load_build
(
Unpicklerobject
*
self
)
{
PyObject
*
value
=
0
,
*
inst
=
0
,
*
instdict
=
0
,
*
d_key
=
0
,
*
d_value
=
0
,
*
junk
=
0
,
*
__setstate__
=
0
;
int
i
,
r
=
0
;
...
...
@@ -3579,7 +3709,8 @@ load_build(Unpicklerobject *self) {
static
int
load_mark
(
Unpicklerobject
*
self
)
{
load_mark
(
Unpicklerobject
*
self
)
{
int
s
;
/* Note that we split the (pickle.py) stack into two stacks, an
...
...
@@ -3593,7 +3724,8 @@ load_mark(Unpicklerobject *self) {
if
(
self
->
marks
==
NULL
)
self
->
marks
=
(
int
*
)
malloc
(
s
*
sizeof
(
int
));
else
self
->
marks
=
(
int
*
)
realloc
(
self
->
marks
,
s
*
sizeof
(
int
));
self
->
marks
=
(
int
*
)
realloc
(
self
->
marks
,
s
*
sizeof
(
int
));
if
(
!
self
->
marks
)
{
PyErr_NoMemory
();
return
-
1
;
...
...
@@ -3607,7 +3739,8 @@ load_mark(Unpicklerobject *self) {
}
static
int
load_reduce
(
Unpicklerobject
*
self
)
{
load_reduce
(
Unpicklerobject
*
self
)
{
PyObject
*
callable
=
0
,
*
arg_tup
=
0
,
*
ob
=
0
;
PDATA_POP
(
self
->
stack
,
arg_tup
);
...
...
@@ -3626,7 +3759,8 @@ load_reduce(Unpicklerobject *self) {
}
static
PyObject
*
load
(
Unpicklerobject
*
self
)
{
load
(
Unpicklerobject
*
self
)
{
PyObject
*
err
=
0
,
*
val
=
0
;
char
*
s
;
...
...
@@ -3849,7 +3983,8 @@ load(Unpicklerobject *self) {
break
;
default:
cPickle_ErrFormat
(
UnpicklingError
,
"invalid load key, '%s'."
,
cPickle_ErrFormat
(
UnpicklingError
,
"invalid load key, '%s'."
,
"c"
,
s
[
0
]);
return
NULL
;
}
...
...
@@ -3873,7 +4008,8 @@ load(Unpicklerobject *self) {
find persistent references. */
static
int
noload_obj
(
Unpicklerobject
*
self
)
{
noload_obj
(
Unpicklerobject
*
self
)
{
int
i
;
if
((
i
=
marker
(
self
))
<
0
)
return
-
1
;
...
...
@@ -3882,7 +4018,8 @@ noload_obj(Unpicklerobject *self) {
static
int
noload_inst
(
Unpicklerobject
*
self
)
{
noload_inst
(
Unpicklerobject
*
self
)
{
int
i
;
char
*
s
;
...
...
@@ -3895,7 +4032,8 @@ noload_inst(Unpicklerobject *self) {
}
static
int
noload_global
(
Unpicklerobject
*
self
)
{
noload_global
(
Unpicklerobject
*
self
)
{
char
*
s
;
if
((
*
self
->
readline_func
)(
self
,
&
s
)
<
0
)
return
-
1
;
...
...
@@ -3905,7 +4043,8 @@ noload_global(Unpicklerobject *self) {
}
static
int
noload_reduce
(
Unpicklerobject
*
self
)
{
noload_reduce
(
Unpicklerobject
*
self
)
{
if
(
self
->
stack
->
length
<
2
)
return
stackUnderflow
();
Pdata_clear
(
self
->
stack
,
self
->
stack
->
length
-
2
);
...
...
@@ -3923,7 +4062,8 @@ noload_build(Unpicklerobject *self) {
static
PyObject
*
noload
(
Unpicklerobject
*
self
)
{
noload
(
Unpicklerobject
*
self
)
{
PyObject
*
err
=
0
,
*
val
=
0
;
char
*
s
;
...
...
@@ -4141,7 +4281,8 @@ noload(Unpicklerobject *self) {
continue
;
default:
cPickle_ErrFormat
(
UnpicklingError
,
"invalid load key, '%s'."
,
cPickle_ErrFormat
(
UnpicklingError
,
"invalid load key, '%s'."
,
"c"
,
s
[
0
]);
return
NULL
;
}
...
...
@@ -4162,7 +4303,8 @@ noload(Unpicklerobject *self) {
static
PyObject
*
Unpickler_load
(
Unpicklerobject
*
self
,
PyObject
*
args
)
{
Unpickler_load
(
Unpicklerobject
*
self
,
PyObject
*
args
)
{
if
(
!
(
PyArg_ParseTuple
(
args
,
":load"
)))
return
NULL
;
...
...
@@ -4170,7 +4312,8 @@ Unpickler_load(Unpicklerobject *self, PyObject *args) {
}
static
PyObject
*
Unpickler_noload
(
Unpicklerobject
*
self
,
PyObject
*
args
)
{
Unpickler_noload
(
Unpicklerobject
*
self
,
PyObject
*
args
)
{
if
(
!
(
PyArg_ParseTuple
(
args
,
":noload"
)))
return
NULL
;
...
...
@@ -4195,7 +4338,8 @@ static struct PyMethodDef Unpickler_methods[] = {
static
Unpicklerobject
*
newUnpicklerobject
(
PyObject
*
f
)
{
newUnpicklerobject
(
PyObject
*
f
)
{
Unpicklerobject
*
self
;
if
(
!
(
self
=
PyObject_New
(
Unpicklerobject
,
&
Unpicklertype
)))
...
...
@@ -4225,7 +4369,8 @@ newUnpicklerobject(PyObject *f) {
if
(
PyFile_Check
(
f
))
{
self
->
fp
=
PyFile_AsFile
(
f
);
if
(
self
->
fp
==
NULL
)
{
PyErr_SetString
(
PyExc_ValueError
,
"I/O operation on closed file"
);
PyErr_SetString
(
PyExc_ValueError
,
"I/O operation on closed file"
);
goto
err
;
}
self
->
read_func
=
read_file
;
...
...
@@ -4245,7 +4390,8 @@ newUnpicklerobject(PyObject *f) {
if
(
!
(
(
self
->
readline
=
PyObject_GetAttr
(
f
,
readline_str
))
&&
(
self
->
read
=
PyObject_GetAttr
(
f
,
read_str
))))
{
PyErr_Clear
();
PyErr_SetString
(
PyExc_TypeError
,
"argument must have 'read' and "
PyErr_SetString
(
PyExc_TypeError
,
"argument must have 'read' and "
"'readline' attributes"
);
goto
err
;
}
...
...
@@ -4256,7 +4402,8 @@ newUnpicklerobject(PyObject *f) {
PyObject
*
m
;
if
(
!
(
m
=
PyImport_Import
(
copy_reg_str
)))
goto
err
;
self
->
safe_constructors
=
PyObject_GetAttr
(
m
,
safe_constructors_str
);
self
->
safe_constructors
=
PyObject_GetAttr
(
m
,
safe_constructors_str
);
Py_DECREF
(
m
);
if
(
!
(
self
->
safe_constructors
))
goto
err
;
}
...
...
@@ -4267,14 +4414,15 @@ newUnpicklerobject(PyObject *f) {
return
self
;
err:
err:
Py_DECREF
((
PyObject
*
)
self
);
return
NULL
;
}
static
PyObject
*
get_Unpickler
(
PyObject
*
self
,
PyObject
*
args
)
{
get_Unpickler
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
file
;
if
(
!
(
PyArg_ParseTuple
(
args
,
"O:Unpickler"
,
&
file
)))
...
...
@@ -4284,7 +4432,8 @@ get_Unpickler(PyObject *self, PyObject *args) {
static
void
Unpickler_dealloc
(
Unpicklerobject
*
self
)
{
Unpickler_dealloc
(
Unpicklerobject
*
self
)
{
Py_XDECREF
(
self
->
readline
);
Py_XDECREF
(
self
->
read
);
Py_XDECREF
(
self
->
file
);
...
...
@@ -4308,7 +4457,8 @@ Unpickler_dealloc(Unpicklerobject *self) {
static
PyObject
*
Unpickler_getattr
(
Unpicklerobject
*
self
,
char
*
name
)
{
Unpickler_getattr
(
Unpicklerobject
*
self
,
char
*
name
)
{
if
(
!
strcmp
(
name
,
"persistent_load"
))
{
if
(
!
self
->
pers_func
)
{
PyErr_SetString
(
PyExc_AttributeError
,
name
);
...
...
@@ -4349,7 +4499,8 @@ Unpickler_getattr(Unpicklerobject *self, char *name) {
static
int
Unpickler_setattr
(
Unpicklerobject
*
self
,
char
*
name
,
PyObject
*
value
)
{
Unpickler_setattr
(
Unpicklerobject
*
self
,
char
*
name
,
PyObject
*
value
)
{
if
(
!
strcmp
(
name
,
"persistent_load"
))
{
Py_XDECREF
(
self
->
pers_func
);
...
...
@@ -4373,7 +4524,8 @@ Unpickler_setattr(Unpicklerobject *self, char *name, PyObject *value) {
if
(
strcmp
(
name
,
"memo"
)
==
0
)
{
if
(
!
PyDict_Check
(
value
))
{
PyErr_SetString
(
PyExc_TypeError
,
"memo must be a dictionary"
);
PyErr_SetString
(
PyExc_TypeError
,
"memo must be a dictionary"
);
return
-
1
;
}
Py_XDECREF
(
self
->
memo
);
...
...
@@ -4388,7 +4540,8 @@ Unpickler_setattr(Unpicklerobject *self, char *name, PyObject *value) {
static
PyObject
*
cpm_dump
(
PyObject
*
self
,
PyObject
*
args
)
{
cpm_dump
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
ob
,
*
file
,
*
res
=
NULL
;
Picklerobject
*
pickler
=
0
;
int
bin
=
0
;
...
...
@@ -4405,7 +4558,7 @@ cpm_dump(PyObject *self, PyObject *args) {
Py_INCREF
(
Py_None
);
res
=
Py_None
;
finally:
finally:
Py_XDECREF
(
pickler
);
return
res
;
...
...
@@ -4413,7 +4566,8 @@ finally:
static
PyObject
*
cpm_dumps
(
PyObject
*
self
,
PyObject
*
args
)
{
cpm_dumps
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
ob
,
*
file
=
0
,
*
res
=
NULL
;
Picklerobject
*
pickler
=
0
;
int
bin
=
0
;
...
...
@@ -4432,7 +4586,7 @@ cpm_dumps(PyObject *self, PyObject *args) {
res
=
PycStringIO
->
cgetvalue
(
file
);
finally:
finally:
Py_XDECREF
(
pickler
);
Py_XDECREF
(
file
);
...
...
@@ -4441,7 +4595,8 @@ finally:
static
PyObject
*
cpm_load
(
PyObject
*
self
,
PyObject
*
args
)
{
cpm_load
(
PyObject
*
self
,
PyObject
*
args
)
{
Unpicklerobject
*
unpickler
=
0
;
PyObject
*
ob
,
*
res
=
NULL
;
...
...
@@ -4453,7 +4608,7 @@ cpm_load(PyObject *self, PyObject *args) {
res
=
load
(
unpickler
);
finally:
finally:
Py_XDECREF
(
unpickler
);
return
res
;
...
...
@@ -4461,7 +4616,8 @@ finally:
static
PyObject
*
cpm_loads
(
PyObject
*
self
,
PyObject
*
args
)
{
cpm_loads
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
ob
,
*
file
=
0
,
*
res
=
NULL
;
Unpicklerobject
*
unpickler
=
0
;
...
...
@@ -4476,7 +4632,7 @@ cpm_loads(PyObject *self, PyObject *args) {
res
=
load
(
unpickler
);
finally:
finally:
Py_XDECREF
(
file
);
Py_XDECREF
(
unpickler
);
...
...
@@ -4546,7 +4702,8 @@ static struct PyMethodDef cPickle_methods[] = {
};
static
int
init_stuff
(
PyObject
*
module_dict
)
{
init_stuff
(
PyObject
*
module_dict
)
{
PyObject
*
copy_reg
,
*
t
,
*
r
;
#define INIT_STR(S) if (!( S ## _str=PyString_InternFromString(#S))) return -1;
...
...
@@ -4574,8 +4731,8 @@ init_stuff(PyObject *module_dict) {
/* These next few are special because we want to use different
ones in restricted mode. */
if
(
!
(
dispatch_table
=
PyObject_GetAttr
(
copy_reg
,
dispatch_table_str
))
)
dispatch_table
=
PyObject_GetAttr
(
copy_reg
,
dispatch_table_str
);
if
(
!
dispatch_table
)
return
-
1
;
if
(
!
(
safe_constructors
=
PyObject_GetAttr
(
copy_reg
,
...
...
@@ -4603,14 +4760,15 @@ init_stuff(PyObject *module_dict) {
module_dict
,
t
)
))
return
-
1
;
Py_DECREF
(
r
);
if
(
!
(
PickleError
=
PyErr_NewException
(
"cPickle.PickleError"
,
NULL
,
t
)))
PickleError
=
PyErr_NewException
(
"cPickle.PickleError"
,
NULL
,
t
);
if
(
!
PickleError
)
return
-
1
;
Py_DECREF
(
t
);
if
(
!
(
PicklingError
=
PyErr_NewException
(
"cPickle.PicklingError"
,
PickleError
,
NULL
))
)
PicklingError
=
PyErr_NewException
(
"cPickle.PicklingError"
,
PickleError
,
NULL
);
if
(
!
PicklingError
)
return
-
1
;
if
(
!
(
t
=
PyDict_New
()))
return
-
1
;
...
...
@@ -4666,7 +4824,8 @@ init_stuff(PyObject *module_dict) {
#define DL_EXPORT(RTYPE) RTYPE
#endif
DL_EXPORT
(
void
)
initcPickle
(
void
)
{
initcPickle
(
void
)
{
PyObject
*
m
,
*
d
,
*
di
,
*
v
,
*
k
;
int
i
;
char
*
rev
=
"1.71"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment