]> granicus.if.org Git - python/commitdiff
frame_traverse(): Use the standard Py_VISIT macro.
authorTim Peters <tim.peters@gmail.com>
Sat, 15 Apr 2006 03:22:46 +0000 (03:22 +0000)
committerTim Peters <tim.peters@gmail.com>
Sat, 15 Apr 2006 03:22:46 +0000 (03:22 +0000)
Py_VISIT:  cast the `op` argument to PyObject* when calling
`visit()`.  Else the caller has to pay too much attention to
this silly detail (e.g., frame_traverse needs to traverse
`struct _frame *` and `PyCodeObject *` pointers too).

Include/objimpl.h
Objects/frameobject.c

index 447a56e4a2776eea961f81746bafa1138dad6199..03b6a8d49dccc1cef611cc541f993769d285a1b4 100644 (file)
@@ -303,13 +303,13 @@ PyAPI_FUNC(void) PyObject_GC_Del(void *);
  * "visit" and "arg".  This is intended to keep tp_traverse functions
  * looking as much alike as possible.
  */
-#define Py_VISIT(op)                                   \
-        do {                                           \
-                if (op) {                              \
-                        int vret = visit((op), arg);   \
-                        if (vret)                      \
-                                return vret;           \
-                }                                      \
+#define Py_VISIT(op)                                                   \
+        do {                                                           \
+                if (op) {                                              \
+                        int vret = visit((PyObject *)(op), arg);       \
+                        if (vret)                                      \
+                                return vret;                           \
+                }                                                      \
         } while (0)
 
 /* This is here for the sake of backwards compatibility.  Extensions that
index 19059966e432621e4dea1af63a5bff5229a733e5..217f4ba7a976d24149006c849ec19b18b282f174 100644 (file)
@@ -422,30 +422,28 @@ static int
 frame_traverse(PyFrameObject *f, visitproc visit, void *arg)
 {
        PyObject **fastlocals, **p;
-       int i, err, slots;
-#define VISIT(o) if (o) {if ((err = visit((PyObject *)(o), arg))) return err;}
-
-       VISIT(f->f_back);
-       VISIT(f->f_code);
-       VISIT(f->f_builtins);
-       VISIT(f->f_globals);
-       VISIT(f->f_locals);
-       VISIT(f->f_trace);
-       VISIT(f->f_exc_type);
-       VISIT(f->f_exc_value);
-       VISIT(f->f_exc_traceback);
+       int i, slots;
+
+       Py_VISIT(f->f_back);
+       Py_VISIT(f->f_code);
+       Py_VISIT(f->f_builtins);
+       Py_VISIT(f->f_globals);
+       Py_VISIT(f->f_locals);
+       Py_VISIT(f->f_trace);
+       Py_VISIT(f->f_exc_type);
+       Py_VISIT(f->f_exc_value);
+       Py_VISIT(f->f_exc_traceback);
 
        /* locals */
        slots = f->f_nlocals + f->f_ncells + f->f_nfreevars;
        fastlocals = f->f_localsplus;
-       for (i = slots; --i >= 0; ++fastlocals) {
-               VISIT(*fastlocals);
-       }
+       for (i = slots; --i >= 0; ++fastlocals)
+               Py_VISIT(*fastlocals);
 
        /* stack */
        if (f->f_stacktop != NULL) {
                for (p = f->f_valuestack; p < f->f_stacktop; p++)
-                       VISIT(*p);
+                       Py_VISIT(*p);
        }
        return 0;
 }