Fix ast_error_finish() and err_input(): filename can be NULL

Fix my previous commit (r85569).
This commit is contained in:
Victor Stinner 2010-10-16 13:42:53 +00:00
parent 4c7c8c3023
commit 2f2ed1f36c
2 changed files with 12 additions and 2 deletions

View file

@ -131,7 +131,12 @@ ast_error_finish(const char *filename)
Py_INCREF(Py_None); Py_INCREF(Py_None);
loc = Py_None; loc = Py_None;
} }
filename_obj = PyUnicode_DecodeFSDefault(filename); if (filename != NULL)
filename_obj = PyUnicode_DecodeFSDefault(filename);
else {
Py_INCREF(Py_None);
filename_obj = Py_None;
}
if (filename_obj != NULL) if (filename_obj != NULL)
tmp = Py_BuildValue("(NlOO)", filename_obj, lineno, offset, loc); tmp = Py_BuildValue("(NlOO)", filename_obj, lineno, offset, loc);
else else

View file

@ -2054,7 +2054,12 @@ err_input(perrdetail *err)
errtext = PyUnicode_DecodeUTF8(err->text, strlen(err->text), errtext = PyUnicode_DecodeUTF8(err->text, strlen(err->text),
"replace"); "replace");
} }
filename = PyUnicode_DecodeFSDefault(err->filename); if (err->filename != NULL)
filename = PyUnicode_DecodeFSDefault(err->filename);
else {
Py_INCREF(Py_None);
filename = Py_None;
}
if (filename != NULL) if (filename != NULL)
v = Py_BuildValue("(NiiN)", filename, v = Py_BuildValue("(NiiN)", filename,
err->lineno, err->offset, errtext); err->lineno, err->offset, errtext);