summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-04-03 04:30:38 (GMT)
committerBenjamin Peterson <benjamin@python.org>2012-04-03 04:30:38 (GMT)
commitb9348e76e40f9324330b496824d81941e9ee69d8 (patch)
tree34ba3d6d4c2fcd615d9b9c82a149e8a8507e85b3 /Python
parentb6e21a0725bdbcf56d232b2be72998934438422d (diff)
downloadcpython-b9348e76e40f9324330b496824d81941e9ee69d8.zip
cpython-b9348e76e40f9324330b496824d81941e9ee69d8.tar.gz
cpython-b9348e76e40f9324330b496824d81941e9ee69d8.tar.bz2
fix parse_syntax_error to clean up its resources
Diffstat (limited to 'Python')
-rw-r--r--Python/pythonrun.c50
1 files changed, 31 insertions, 19 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index dcb2c0e..afb4c51 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -989,55 +989,67 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
return PyArg_ParseTuple(err, "O(ziiz)", message, filename,
lineno, offset, text);
- /* new style errors. `err' is an instance */
+ *message = NULL;
- if (! (v = PyObject_GetAttrString(err, "msg")))
+ /* new style errors. `err' is an instance */
+ *message = PyObject_GetAttrString(err, "msg");
+ if (!*message)
goto finally;
- *message = v;
- if (!(v = PyObject_GetAttrString(err, "filename")))
+ v = PyObject_GetAttrString(err, "filename");
+ if (!v)
goto finally;
- if (v == Py_None)
+ if (v == Py_None) {
+ Py_DECREF(v);
*filename = NULL;
- else if (! (*filename = PyString_AsString(v)))
- goto finally;
+ }
+ else {
+ *filename = PyString_AsString(v);
+ Py_DECREF(v);
+ if (!*filename)
+ goto finally;
+ }
- Py_DECREF(v);
- if (!(v = PyObject_GetAttrString(err, "lineno")))
+ v = PyObject_GetAttrString(err, "lineno");
+ if (!v)
goto finally;
hold = PyInt_AsLong(v);
Py_DECREF(v);
- v = NULL;
if (hold < 0 && PyErr_Occurred())
goto finally;
*lineno = (int)hold;
- if (!(v = PyObject_GetAttrString(err, "offset")))
+ v = PyObject_GetAttrString(err, "offset");
+ if (!v)
goto finally;
if (v == Py_None) {
*offset = -1;
Py_DECREF(v);
- v = NULL;
} else {
hold = PyInt_AsLong(v);
Py_DECREF(v);
- v = NULL;
if (hold < 0 && PyErr_Occurred())
goto finally;
*offset = (int)hold;
}
- if (!(v = PyObject_GetAttrString(err, "text")))
+ v = PyObject_GetAttrString(err, "text");
+ if (!v)
goto finally;
- if (v == Py_None)
+ if (v == Py_None) {
+ Py_DECREF(v);
*text = NULL;
- else if (! (*text = PyString_AsString(v)))
- goto finally;
- Py_DECREF(v);
+ }
+ else {
+ *text = PyString_AsString(v);
+ Py_DECREF(v);
+ if (!*text)
+ goto finally;
+ }
return 1;
finally:
- Py_XDECREF(v);
+ Py_XDECREF(*message);
return 0;
}
vkK tJdd(Eih `QCIA|7 OSP7k ҉E";TBWRd{rv >tԡǓ.!Q32MBxVJK0R:X"] ]ASq߲jO4-!8ȳ#:g^u.4-n< r\/B^&a|ws_vQGVFԕy1vQk"r$H@8wYU}Ie_#MXP{EMx*^Rvb]7VTxJcŒ3vjؾ| d(N:!OA#> ]J,Ϸ]wY 2(zsCl<% I Tn֙.uA%1TԅwPiꅦQen,ymf Spz%ԒI@l/xTnoGjNTA3/L,g2͒ jN3jO fB$ˍ_{;ΰCSfgH ,hʟX{HbIM+$ vԂmCYbceSOYS =kn>`/$w腾>#Fz=-۪hqҘ-7{}k52!Kmv| ~Ĺ6liq[F(%ރjffr,RhdVMW~H!`nq\a.Q[%Z}5vsJpMy(xnP2Y>KV[Yp$%_*2nH2Lz4$ ;')X7 @s#{ԕ&kLSy/ctFEi -vb&!yvaAmxʱ mF֬\kTz|^Krч>5UkO}?A{WxwO8%ٜԝ a̖pxσ X/n_:H9m83S`U%IlZ*&h5Ŷ}I:zd25s̖ؒ>rvm}iolhtZ7xqWoDfeCw[6>SFeQ7^"9(ZcOCv[ 1o' {:|xau=/@R SK2Ex??>>|m)Tz=: >-dj}drOh_O~ h