summaryrefslogtreecommitdiffstats
path: root/Modules/parsermodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/parsermodule.c')
-rw-r--r--Modules/parsermodule.c48
1 files changed, 16 insertions, 32 deletions
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
index 2c079ad..b4602f5 100644
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -382,36 +382,28 @@ parser_sizeof(PyST_Object *st, void *unused)
static PyObject*
parser_st2tuple(PyST_Object *self, PyObject *args, PyObject *kw)
{
- PyObject *line_option = 0;
- PyObject *col_option = 0;
+ int line_info = 0;
+ int col_info = 0;
PyObject *res = 0;
int ok;
static char *keywords[] = {"st", "line_info", "col_info", NULL};
if (self == NULL || PyModule_Check(self)) {
- ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|OO:st2tuple", keywords,
- &PyST_Type, &self, &line_option,
- &col_option);
+ ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|pp:st2tuple", keywords,
+ &PyST_Type, &self, &line_info,
+ &col_info);
}
else
- ok = PyArg_ParseTupleAndKeywords(args, kw, "|OO:totuple", &keywords[1],
- &line_option, &col_option);
+ ok = PyArg_ParseTupleAndKeywords(args, kw, "|pp:totuple", &keywords[1],
+ &line_info, &col_info);
if (ok != 0) {
- int lineno = 0;
- int col_offset = 0;
- if (line_option != NULL) {
- lineno = (PyObject_IsTrue(line_option) != 0) ? 1 : 0;
- }
- if (col_option != NULL) {
- col_offset = (PyObject_IsTrue(col_option) != 0) ? 1 : 0;
- }
/*
* Convert ST into a tuple representation. Use Guido's function,
* since it's known to work already.
*/
res = node2tuple(((PyST_Object*)self)->st_node,
- PyTuple_New, PyTuple_SetItem, lineno, col_offset);
+ PyTuple_New, PyTuple_SetItem, line_info, col_info);
}
return (res);
}
@@ -426,35 +418,27 @@ parser_st2tuple(PyST_Object *self, PyObject *args, PyObject *kw)
static PyObject*
parser_st2list(PyST_Object *self, PyObject *args, PyObject *kw)
{
- PyObject *line_option = 0;
- PyObject *col_option = 0;
+ int line_info = 0;
+ int col_info = 0;
PyObject *res = 0;
int ok;
static char *keywords[] = {"st", "line_info", "col_info", NULL};
if (self == NULL || PyModule_Check(self))
- ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|OO:st2list", keywords,
- &PyST_Type, &self, &line_option,
- &col_option);
+ ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|pp:st2list", keywords,
+ &PyST_Type, &self, &line_info,
+ &col_info);
else
- ok = PyArg_ParseTupleAndKeywords(args, kw, "|OO:tolist", &keywords[1],
- &line_option, &col_option);
+ ok = PyArg_ParseTupleAndKeywords(args, kw, "|pp:tolist", &keywords[1],
+ &line_info, &col_info);
if (ok) {
- int lineno = 0;
- int col_offset = 0;
- if (line_option != 0) {
- lineno = PyObject_IsTrue(line_option) ? 1 : 0;
- }
- if (col_option != NULL) {
- col_offset = (PyObject_IsTrue(col_option) != 0) ? 1 : 0;
- }
/*
* Convert ST into a tuple representation. Use Guido's function,
* since it's known to work already.
*/
res = node2tuple(self->st_node,
- PyList_New, PyList_SetItem, lineno, col_offset);
+ PyList_New, PyList_SetItem, line_info, col_info);
}
return (res);
}