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
81c25f38
Commit
81c25f38
authored
Apr 15, 2006
by
Thomas Wouters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Py_CLEAR instead of in-place DECREF/XDECREF or custom macros, for
tp_clear methods.
parent
5dbb5ea0
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
30 additions
and
57 deletions
+30
-57
Modules/_csv.c
Modules/_csv.c
+5
-10
Modules/cPickle.c
Modules/cPickle.c
+17
-21
Modules/collectionsmodule.c
Modules/collectionsmodule.c
+1
-4
Modules/pyexpat.c
Modules/pyexpat.c
+1
-2
Objects/cellobject.c
Objects/cellobject.c
+1
-2
Objects/funcobject.c
Objects/funcobject.c
+1
-3
Objects/typeobject.c
Objects/typeobject.c
+2
-11
Python/traceback.c
Python/traceback.c
+2
-4
No files found.
Modules/_csv.c
View file @
81c25f38
...
@@ -828,12 +828,9 @@ Reader_traverse(ReaderObj *self, visitproc visit, void *arg)
...
@@ -828,12 +828,9 @@ Reader_traverse(ReaderObj *self, visitproc visit, void *arg)
static
int
static
int
Reader_clear
(
ReaderObj
*
self
)
Reader_clear
(
ReaderObj
*
self
)
{
{
Py_XDECREF
(
self
->
dialect
);
Py_CLEAR
(
self
->
dialect
);
Py_XDECREF
(
self
->
input_iter
);
Py_CLEAR
(
self
->
input_iter
);
Py_XDECREF
(
self
->
fields
);
Py_CLEAR
(
self
->
fields
);
self
->
dialect
=
NULL
;
self
->
input_iter
=
NULL
;
self
->
fields
=
NULL
;
return
0
;
return
0
;
}
}
...
@@ -1260,10 +1257,8 @@ Writer_traverse(WriterObj *self, visitproc visit, void *arg)
...
@@ -1260,10 +1257,8 @@ Writer_traverse(WriterObj *self, visitproc visit, void *arg)
static
int
static
int
Writer_clear
(
WriterObj
*
self
)
Writer_clear
(
WriterObj
*
self
)
{
{
Py_XDECREF
(
self
->
dialect
);
Py_CLEAR
(
self
->
dialect
);
Py_XDECREF
(
self
->
writeline
);
Py_CLEAR
(
self
->
writeline
);
self
->
dialect
=
NULL
;
self
->
writeline
=
NULL
;
return
0
;
return
0
;
}
}
...
...
Modules/cPickle.c
View file @
81c25f38
...
@@ -2931,16 +2931,14 @@ Pickler_traverse(Picklerobject *self, visitproc visit, void *arg)
...
@@ -2931,16 +2931,14 @@ Pickler_traverse(Picklerobject *self, visitproc visit, void *arg)
static
int
static
int
Pickler_clear
(
Picklerobject
*
self
)
Pickler_clear
(
Picklerobject
*
self
)
{
{
#define CLEAR(SLOT) Py_XDECREF(SLOT); SLOT = NULL;
Py_CLEAR
(
self
->
write
);
CLEAR
(
self
->
write
);
Py_CLEAR
(
self
->
memo
);
CLEAR
(
self
->
memo
);
Py_CLEAR
(
self
->
fast_memo
);
CLEAR
(
self
->
fast_memo
);
Py_CLEAR
(
self
->
arg
);
CLEAR
(
self
->
arg
);
Py_CLEAR
(
self
->
file
);
CLEAR
(
self
->
file
);
Py_CLEAR
(
self
->
pers_func
);
CLEAR
(
self
->
pers_func
);
Py_CLEAR
(
self
->
inst_pers_func
);
CLEAR
(
self
->
inst_pers_func
);
Py_CLEAR
(
self
->
dispatch_table
);
CLEAR
(
self
->
dispatch_table
);
#undef CLEAR
return
0
;
return
0
;
}
}
...
@@ -5284,17 +5282,15 @@ Unpickler_traverse(Unpicklerobject *self, visitproc visit, void *arg)
...
@@ -5284,17 +5282,15 @@ Unpickler_traverse(Unpicklerobject *self, visitproc visit, void *arg)
static
int
static
int
Unpickler_clear
(
Unpicklerobject
*
self
)
Unpickler_clear
(
Unpicklerobject
*
self
)
{
{
#define CLEAR(SLOT) Py_XDECREF(SLOT); SLOT = NULL
Py_CLEAR
(
self
->
readline
);
CLEAR
(
self
->
readline
);
Py_CLEAR
(
self
->
read
);
CLEAR
(
self
->
read
);
Py_CLEAR
(
self
->
file
);
CLEAR
(
self
->
file
);
Py_CLEAR
(
self
->
memo
);
CLEAR
(
self
->
memo
);
Py_CLEAR
(
self
->
stack
);
CLEAR
(
self
->
stack
);
Py_CLEAR
(
self
->
pers_func
);
CLEAR
(
self
->
pers_func
);
Py_CLEAR
(
self
->
arg
);
CLEAR
(
self
->
arg
);
Py_CLEAR
(
self
->
last_string
);
CLEAR
(
self
->
last_string
);
Py_CLEAR
(
self
->
find_class
);
CLEAR
(
self
->
find_class
);
#undef CLEAR
return
0
;
return
0
;
}
}
...
...
Modules/collectionsmodule.c
View file @
81c25f38
...
@@ -1236,10 +1236,7 @@ defdict_traverse(PyObject *self, visitproc visit, void *arg)
...
@@ -1236,10 +1236,7 @@ defdict_traverse(PyObject *self, visitproc visit, void *arg)
static
int
static
int
defdict_tp_clear
(
defdictobject
*
dd
)
defdict_tp_clear
(
defdictobject
*
dd
)
{
{
if
(
dd
->
default_factory
!=
NULL
)
{
Py_CLEAR
(
dd
->
default_factory
);
Py_DECREF
(
dd
->
default_factory
);
dd
->
default_factory
=
NULL
;
}
return
PyDict_Type
.
tp_clear
((
PyObject
*
)
dd
);
return
PyDict_Type
.
tp_clear
((
PyObject
*
)
dd
);
}
}
...
...
Modules/pyexpat.c
View file @
81c25f38
...
@@ -1669,8 +1669,7 @@ static int
...
@@ -1669,8 +1669,7 @@ static int
xmlparse_clear
(
xmlparseobject
*
op
)
xmlparse_clear
(
xmlparseobject
*
op
)
{
{
clear_handlers
(
op
,
0
);
clear_handlers
(
op
,
0
);
Py_XDECREF
(
op
->
intern
);
Py_CLEAR
(
op
->
intern
);
op
->
intern
=
0
;
return
0
;
return
0
;
}
}
#endif
#endif
...
...
Objects/cellobject.c
View file @
81c25f38
...
@@ -81,8 +81,7 @@ cell_traverse(PyCellObject *op, visitproc visit, void *arg)
...
@@ -81,8 +81,7 @@ cell_traverse(PyCellObject *op, visitproc visit, void *arg)
static
int
static
int
cell_clear
(
PyCellObject
*
op
)
cell_clear
(
PyCellObject
*
op
)
{
{
Py_XDECREF
(
op
->
ob_ref
);
Py_CLEAR
(
op
->
ob_ref
);
op
->
ob_ref
=
NULL
;
return
0
;
return
0
;
}
}
...
...
Objects/funcobject.c
View file @
81c25f38
...
@@ -655,9 +655,7 @@ cm_traverse(classmethod *cm, visitproc visit, void *arg)
...
@@ -655,9 +655,7 @@ cm_traverse(classmethod *cm, visitproc visit, void *arg)
static
int
static
int
cm_clear
(
classmethod
*
cm
)
cm_clear
(
classmethod
*
cm
)
{
{
Py_XDECREF
(
cm
->
cm_callable
);
Py_CLEAR
(
cm
->
cm_callable
);
cm
->
cm_callable
=
NULL
;
return
0
;
return
0
;
}
}
...
...
Objects/typeobject.c
View file @
81c25f38
...
@@ -559,8 +559,8 @@ clear_slots(PyTypeObject *type, PyObject *self)
...
@@ -559,8 +559,8 @@ clear_slots(PyTypeObject *type, PyObject *self)
char
*
addr
=
(
char
*
)
self
+
mp
->
offset
;
char
*
addr
=
(
char
*
)
self
+
mp
->
offset
;
PyObject
*
obj
=
*
(
PyObject
**
)
addr
;
PyObject
*
obj
=
*
(
PyObject
**
)
addr
;
if
(
obj
!=
NULL
)
{
if
(
obj
!=
NULL
)
{
Py_DECREF
(
obj
);
*
(
PyObject
**
)
addr
=
NULL
;
*
(
PyObject
**
)
addr
=
NULL
;
Py_DECREF
(
obj
);
}
}
}
}
}
}
...
@@ -2236,13 +2236,6 @@ type_clear(PyTypeObject *type)
...
@@ -2236,13 +2236,6 @@ type_clear(PyTypeObject *type)
for heaptypes. */
for heaptypes. */
assert
(
type
->
tp_flags
&
Py_TPFLAGS_HEAPTYPE
);
assert
(
type
->
tp_flags
&
Py_TPFLAGS_HEAPTYPE
);
#define CLEAR(SLOT) \
if (SLOT) { \
tmp = (PyObject *)(SLOT); \
SLOT = NULL; \
Py_DECREF(tmp); \
}
/* The only field we need to clear is tp_mro, which is part of a
/* The only field we need to clear is tp_mro, which is part of a
hard cycle (its first element is the class itself) that won't
hard cycle (its first element is the class itself) that won't
be broken otherwise (it's a tuple and tuples don't have a
be broken otherwise (it's a tuple and tuples don't have a
...
@@ -2268,9 +2261,7 @@ type_clear(PyTypeObject *type)
...
@@ -2268,9 +2261,7 @@ type_clear(PyTypeObject *type)
A tuple of strings can't be part of a cycle.
A tuple of strings can't be part of a cycle.
*/
*/
CLEAR
(
type
->
tp_mro
);
Py_CLEAR
(
type
->
tp_mro
);
#undef CLEAR
return
0
;
return
0
;
}
}
...
...
Python/traceback.c
View file @
81c25f38
...
@@ -53,10 +53,8 @@ tb_traverse(PyTracebackObject *tb, visitproc visit, void *arg)
...
@@ -53,10 +53,8 @@ tb_traverse(PyTracebackObject *tb, visitproc visit, void *arg)
static
void
static
void
tb_clear
(
PyTracebackObject
*
tb
)
tb_clear
(
PyTracebackObject
*
tb
)
{
{
Py_XDECREF
(
tb
->
tb_next
);
Py_CLEAR
(
tb
->
tb_next
);
Py_XDECREF
(
tb
->
tb_frame
);
Py_CLEAR
(
tb
->
tb_frame
);
tb
->
tb_next
=
NULL
;
tb
->
tb_frame
=
NULL
;
}
}
PyTypeObject
PyTraceBack_Type
=
{
PyTypeObject
PyTraceBack_Type
=
{
...
...
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