summaryrefslogtreecommitdiffstats
path: root/Objects/genobject.c
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2006-04-15 21:41:56 (GMT)
committerThomas Wouters <thomas@python.org>2006-04-15 21:41:56 (GMT)
commit447d095976fd532bf1882bf7afeb52473ff8673c (patch)
treeab4c1fab54f5db929a41cfe1e2505de8b8a2a23d /Objects/genobject.c
parent112d4ec7d5cd2113d62039cd2d59a410fe61fceb (diff)
downloadcpython-447d095976fd532bf1882bf7afeb52473ff8673c.zip
cpython-447d095976fd532bf1882bf7afeb52473ff8673c.tar.gz
cpython-447d095976fd532bf1882bf7afeb52473ff8673c.tar.bz2
- Whitespace normalization
- In functions where we already hold the same object in differently typed pointers, use the correctly typed pointer instead of casting the other pointer a second time.
Diffstat (limited to 'Objects/genobject.c')
-rw-r--r--Objects/genobject.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c
index c73a53cb..a00aa85 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -22,12 +22,11 @@ gen_dealloc(PyGenObject *gen)
_PyObject_GC_UNTRACK(gen);
if (gen->gi_weakreflist != NULL)
- PyObject_ClearWeakRefs((PyObject *) gen);
-
+ PyObject_ClearWeakRefs(self);
_PyObject_GC_TRACK(self);
- if (gen->gi_frame!=NULL && gen->gi_frame->f_stacktop!=NULL) {
+ if (gen->gi_frame != NULL && gen->gi_frame->f_stacktop != NULL) {
/* Generator is paused, so we need to close */
gen->ob_type->tp_del(self);
if (self->ob_refcnt > 0)
@@ -54,14 +53,16 @@ gen_send_ex(PyGenObject *gen, PyObject *arg, int exc)
}
if (f==NULL || f->f_stacktop == NULL) {
/* Only set exception if called from send() */
- if (arg && !exc) PyErr_SetNone(PyExc_StopIteration);
+ if (arg && !exc)
+ PyErr_SetNone(PyExc_StopIteration);
return NULL;
}
if (f->f_lasti == -1) {
if (arg && arg != Py_None) {
PyErr_SetString(PyExc_TypeError,
- "can't send non-None value to a just-started generator");
+ "can't send non-None value to a "
+ "just-started generator");
return NULL;
}
} else {
@@ -93,7 +94,8 @@ gen_send_ex(PyGenObject *gen, PyObject *arg, int exc)
Py_DECREF(result);
result = NULL;
/* Set exception if not called by gen_iternext() */
- if (arg) PyErr_SetNone(PyExc_StopIteration);
+ if (arg)
+ PyErr_SetNone(PyExc_StopIteration);
}
if (!result || f->f_stacktop == NULL) {
@@ -127,11 +129,11 @@ gen_close(PyGenObject *gen, PyObject *args)
if (retval) {
Py_DECREF(retval);
PyErr_SetString(PyExc_RuntimeError,
- "generator ignored GeneratorExit");
+ "generator ignored GeneratorExit");
return NULL;
}
- if ( PyErr_ExceptionMatches(PyExc_StopIteration)
- || PyErr_ExceptionMatches(PyExc_GeneratorExit) )
+ if (PyErr_ExceptionMatches(PyExc_StopIteration)
+ || PyErr_ExceptionMatches(PyExc_GeneratorExit))
{
PyErr_Clear(); /* ignore these errors */
Py_INCREF(Py_None);
@@ -147,7 +149,7 @@ gen_del(PyObject *self)
PyObject *error_type, *error_value, *error_traceback;
PyGenObject *gen = (PyGenObject *)self;
- if (!gen->gi_frame || gen->gi_frame->f_stacktop==NULL)
+ if (gen->gi_frame == NULL || gen->gi_frame->f_stacktop == NULL)
/* Generator isn't paused, so no need to close */
return;
@@ -158,10 +160,10 @@ gen_del(PyObject *self)
/* Save the current exception, if any. */
PyErr_Fetch(&error_type, &error_value, &error_traceback);
- res = gen_close((PyGenObject *)self, NULL);
+ res = gen_close(gen, NULL);
if (res == NULL)
- PyErr_WriteUnraisable((PyObject *)self);
+ PyErr_WriteUnraisable(self);
else
Py_DECREF(res);