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
4cf6319c
Commit
4cf6319c
authored
Apr 09, 2003
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Picklers collectable.
Bug fix candidate.
parent
d06483c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
5 deletions
+45
-5
Modules/cPickle.c
Modules/cPickle.c
+45
-5
No files found.
Modules/cPickle.c
View file @
4cf6319c
...
...
@@ -2724,7 +2724,7 @@ newPicklerobject(PyObject *file, int proto)
return
NULL
;
}
self
=
PyObject_New
(
Picklerobject
,
&
Picklertype
);
self
=
PyObject_
GC_
New
(
Picklerobject
,
&
Picklertype
);
if
(
self
==
NULL
)
return
NULL
;
self
->
proto
=
proto
;
...
...
@@ -2807,6 +2807,7 @@ newPicklerobject(PyObject *file, int proto)
self
->
dispatch_table
=
dispatch_table
;
Py_INCREF
(
dispatch_table
);
}
PyObject_GC_Track
(
self
);
return
self
;
...
...
@@ -2842,6 +2843,7 @@ get_Pickler(PyObject *self, PyObject *args)
static
void
Pickler_dealloc
(
Picklerobject
*
self
)
{
PyObject_GC_UnTrack
(
self
);
Py_XDECREF
(
self
->
write
);
Py_XDECREF
(
self
->
memo
);
Py_XDECREF
(
self
->
fast_memo
);
...
...
@@ -2851,7 +2853,45 @@ Pickler_dealloc(Picklerobject *self)
Py_XDECREF
(
self
->
inst_pers_func
);
Py_XDECREF
(
self
->
dispatch_table
);
PyMem_Free
(
self
->
write_buf
);
PyObject_Del
(
self
);
PyObject_GC_Del
(
self
);
}
static
int
Pickler_traverse
(
Picklerobject
*
self
,
visitproc
visit
,
void
*
arg
)
{
int
err
;
#define VISIT(SLOT) \
if (SLOT) { \
err = visit((PyObject *)(SLOT), arg); \
if (err) \
return err; \
}
VISIT
(
self
->
write
);
VISIT
(
self
->
memo
);
VISIT
(
self
->
fast_memo
);
VISIT
(
self
->
arg
);
VISIT
(
self
->
file
);
VISIT
(
self
->
pers_func
);
VISIT
(
self
->
inst_pers_func
);
VISIT
(
self
->
dispatch_table
);
#undef VISIT
return
0
;
}
static
int
Pickler_clear
(
Picklerobject
*
self
)
{
#define CLEAR(SLOT) Py_XDECREF(SLOT); SLOT = NULL;
CLEAR
(
self
->
write
);
CLEAR
(
self
->
memo
);
CLEAR
(
self
->
fast_memo
);
CLEAR
(
self
->
arg
);
CLEAR
(
self
->
file
);
CLEAR
(
self
->
pers_func
);
CLEAR
(
self
->
inst_pers_func
);
CLEAR
(
self
->
dispatch_table
);
#undef CLEAR
return
0
;
}
static
PyObject
*
...
...
@@ -2967,10 +3007,10 @@ static PyTypeObject Picklertype = {
PyObject_GenericGetAttr
,
/* tp_getattro */
PyObject_GenericSetAttr
,
/* tp_setattro */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_BASETYPE
,
/* tp_flags */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_BASETYPE
|
Py_TPFLAGS_HAVE_GC
,
Picklertype__doc__
,
/* tp_doc */
0
,
/* tp_traverse */
0
,
/* tp_clear */
(
traverseproc
)
Pickler_traverse
,
/* tp_traverse */
(
inquiry
)
Pickler_clear
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
0
,
/* tp_iter */
...
...
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