Index: pythonrun.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pythonrun.h,v retrieving revision 2.62 diff -c -r2.62 pythonrun.h *** pythonrun.h 13 Feb 2003 22:07:52 -0000 2.62 --- pythonrun.h 4 Aug 2004 19:29:00 -0000 *************** *** 36,42 **** --- 36,45 ---- PyAPI_FUNC(int) PyRun_SimpleString(const char *); PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *); + PyAPI_FUNC(int) PyRun_SimpleFileWithOpen(const char *filename); PyAPI_FUNC(int) PyRun_SimpleFile(FILE *, const char *); + + PyAPI_FUNC(int) PyRun_SimpleFileEx(FILE *, const char *, int); PyAPI_FUNC(int) PyRun_SimpleFileExFlags(FILE *, const char *, int, PyCompilerFlags *); PyAPI_FUNC(int) PyRun_InteractiveOne(FILE *, const char *); Index: pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.207 diff -c -r2.207 pythonrun.c *** pythonrun.c 21 Jul 2004 05:35:02 -0000 2.207 --- pythonrun.c 4 Aug 2004 19:29:00 -0000 *************** *** 13,19 **** --- 13,21 ---- #include "eval.h" #include "marshal.h" + #ifdef HAVE_SIGNAL_H #include + #endif #ifdef HAVE_LANGINFO_H #include *************** *** 25,30 **** --- 27,35 ---- #include "windows.h" #endif + #ifdef macintosh + #include "macglue.h" + #endif extern char *Py_GetPath(void); extern grammar _PyParser_Grammar; /* From graminit.c */ *************** *** 316,322 **** initialized = 0; /* Get current thread state and interpreter pointer */ ! tstate = PyThreadState_GET(); interp = tstate->interp; /* Disable signal handling */ --- 321,327 ---- initialized = 0; /* Get current thread state and interpreter pointer */ ! tstate = PyThreadState_Get(); interp = tstate->interp; /* Disable signal handling */ *************** *** 529,535 **** { PyInterpreterState *interp = tstate->interp; ! if (tstate != PyThreadState_GET()) Py_FatalError("Py_EndInterpreter: thread is not current"); if (tstate->frame != NULL) Py_FatalError("Py_EndInterpreter: thread still has a frame"); --- 534,540 ---- { PyInterpreterState *interp = tstate->interp; ! if (tstate != PyThreadState_Get()) Py_FatalError("Py_EndInterpreter: thread is not current"); if (tstate->frame != NULL) Py_FatalError("Py_EndInterpreter: thread still has a frame"); *************** *** 766,771 **** --- 771,787 ---- return PyRun_SimpleFileEx(fp, filename, 0); } + int + PyRun_SimpleFileWithOpen(const char *filename) + { + FILE *fp = NULL; + + if ((fp = fopen(filename,"r")) == NULL) + return 0; + + return PyRun_SimpleFileEx(fp, filename, 0); + } + /* Check whether a file maybe a pyc file: Look at the extension, the file type, and, if we may close it, at the first few bytes. */ *************** *** 775,780 **** --- 791,803 ---- if (strcmp(ext, ".pyc") == 0 || strcmp(ext, ".pyo") == 0) return 1; + #ifdef macintosh + /* On a mac, we also assume a pyc file for types 'PYC ' and 'APPL' */ + if (PyMac_getfiletype((char *)filename) == 'PYC ' + || PyMac_getfiletype((char *)filename) == 'APPL') + return 1; + #endif /* macintosh */ + /* Only look into the file if we are allowed to close it, since it then should also be seekable. */ if (closeit) { *************** *** 1051,1057 **** } hook = PySys_GetObject("excepthook"); if (hook) { ! PyObject *args = PyTuple_Pack(3, exception, v ? v : Py_None, tb ? tb : Py_None); PyObject *result = PyEval_CallObject(hook, args); if (result == NULL) { --- 1074,1080 ---- } hook = PySys_GetObject("excepthook"); if (hook) { ! PyObject *args = Py_BuildValue("(OOO)", exception, v ? v : Py_None, tb ? tb : Py_None); PyObject *result = PyEval_CallObject(hook, args); if (result == NULL) { *************** *** 1332,1337 **** --- 1355,1361 ---- { node *n; perrdetail err; + n = PyParser_ParseFileFlags(fp, filename, &_PyParser_Grammar, start, (char *)0, (char *)0, &err, flags); if (n == NULL) *************** *** 1435,1442 **** msg = "EOL while scanning single-quoted string"; break; case E_INTR: ! if (!PyErr_Occurred()) ! PyErr_SetNone(PyExc_KeyboardInterrupt); Py_XDECREF(v); return; case E_NOMEM: --- 1459,1465 ---- msg = "EOL while scanning single-quoted string"; break; case E_INTR: ! PyErr_SetNone(PyExc_KeyboardInterrupt); Py_XDECREF(v); return; case E_NOMEM: *************** *** 1462,1468 **** msg = "too many levels of indentation"; break; case E_DECODE: { /* XXX */ ! PyThreadState* tstate = PyThreadState_GET(); PyObject* value = tstate->curexc_value; if (value != NULL) { u = PyObject_Repr(value); --- 1485,1491 ---- msg = "too many levels of indentation"; break; case E_DECODE: { /* XXX */ ! PyThreadState* tstate = PyThreadState_Get(); PyObject* value = tstate->curexc_value; if (value != NULL) { u = PyObject_Repr(value); *************** *** 1471,1479 **** break; } } - if (msg == NULL) - msg = "unknown decode error"; - break; } default: fprintf(stderr, "error=%d\n", err->error); --- 1494,1499 ---- *************** *** 1561,1572 **** --- 1581,1597 ---- { Py_Finalize(); + #ifdef macintosh + PyMac_Exit(sts); + #else exit(sts); + #endif } static void initsigs(void) { + #ifdef HAVE_SIGNAL_H #ifdef SIGPIPE signal(SIGPIPE, SIG_IGN); #endif *************** *** 1576,1584 **** --- 1601,1622 ---- #ifdef SIGXFSZ signal(SIGXFSZ, SIG_IGN); #endif + #endif /* HAVE_SIGNAL_H */ PyOS_InitInterrupts(); /* May imply initsignal() */ } + #ifdef MPW + + /* Check for file descriptor connected to interactive device. + Pretend that stdin is always interactive, other files never. */ + + int + isatty(int fd) + { + return fd == fileno(stdin); + } + + #endif /* * The file descriptor fd is considered ``interactive'' if either