[Python-checkins] python/dist/src/Python import.c,2.208.2.2,2.208.2.3 pythonrun.c,2.161.2.6,2.161.2.7
jhylton@users.sourceforge.net
jhylton@users.sourceforge.net
Fri, 30 Aug 2002 13:55:02 -0700
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv24065/Python
Modified Files:
Tag: ast-branch
import.c pythonrun.c
Log Message:
Extend PyParser_ASTFromFile() with int *errcode argument.
If errocode is non-NULL and an error occurred in the parser, errcode
will be set to the parser errorcode, e.g. E_EOF.
We need this change so that PyRun_InteractiveOneFlags() can detect
E_EOF and exit instead of reporting "unexpected EOF during parsing."
Index: import.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/import.c,v
retrieving revision 2.208.2.2
retrieving revision 2.208.2.3
diff -C2 -d -r2.208.2.2 -r2.208.2.3
*** import.c 16 Aug 2002 20:27:17 -0000 2.208.2.2
--- import.c 30 Aug 2002 20:54:59 -0000 2.208.2.3
***************
*** 658,662 ****
mod_ty mod;
! mod = PyParser_ASTFromFile(fp, pathname, Py_file_input, 0, 0, 0);
if (mod)
co = PyAST_Compile(mod, pathname, NULL);
--- 658,663 ----
mod_ty mod;
! mod = PyParser_ASTFromFile(fp, pathname, Py_file_input, 0, 0, 0,
! NULL);
if (mod)
co = PyAST_Compile(mod, pathname, NULL);
Index: pythonrun.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v
retrieving revision 2.161.2.6
retrieving revision 2.161.2.7
diff -C2 -d -r2.161.2.6 -r2.161.2.7
*** pythonrun.c 30 Aug 2002 20:37:54 -0000 2.161.2.6
--- pythonrun.c 30 Aug 2002 20:55:00 -0000 2.161.2.7
***************
*** 536,539 ****
--- 536,540 ----
mod_ty mod;
char *ps1 = "", *ps2 = "";
+ int errcode = 0;
v = PySys_GetObject("ps1");
***************
*** 555,562 ****
mod = PyParser_ASTFromFile(fp, filename,
Py_single_input, ps1, ps2,
! PARSER_FLAGS(flags));
Py_XDECREF(v);
Py_XDECREF(w);
if (mod == NULL) {
PyErr_Print();
return -1;
--- 556,567 ----
mod = PyParser_ASTFromFile(fp, filename,
Py_single_input, ps1, ps2,
! PARSER_FLAGS(flags), &errcode);
Py_XDECREF(v);
Py_XDECREF(w);
if (mod == NULL) {
+ if (errcode == E_EOF) {
+ PyErr_Clear();
+ return E_EOF;
+ }
PyErr_Print();
return -1;
***************
*** 979,983 ****
{
mod_ty mod = PyParser_ASTFromFile(fp, filename, start, 0, 0,
! PARSER_FLAGS(flags));
if (closeit)
fclose(fp);
--- 984,988 ----
{
mod_ty mod = PyParser_ASTFromFile(fp, filename, start, 0, 0,
! PARSER_FLAGS(flags), NULL);
if (closeit)
fclose(fp);
***************
*** 1087,1091 ****
mod_ty
PyParser_ASTFromFile(FILE *fp, const char *filename, int start, char *ps1,
! char *ps2, int flags)
{
node *n;
--- 1092,1096 ----
mod_ty
PyParser_ASTFromFile(FILE *fp, const char *filename, int start, char *ps1,
! char *ps2, int flags, int *errcode)
{
node *n;
***************
*** 1098,1101 ****
--- 1103,1108 ----
else {
err_input(&err);
+ if (errcode)
+ *errcode = err.error;
return NULL;
}