cinap_lenrekadd hg and python4bb9e2215 years agoHistory
1857 lines · 44.2 KB · C
RawDownload
		break;	case E_TOODEEP:		errtype = PyExc_IndentationError;		msg = "too many levels of indentation";		break;	case E_DECODE: {		PyObject *type, *value, *tb;		PyErr_Fetch(&type, &value, &tb);		if (value != NULL) {			u = PyObject_Str(value);			if (u != NULL) {				msg = PyString_AsString(u);			}		}		if (msg == NULL)			msg = "unknown decode error";		Py_XDECREF(type);		Py_XDECREF(value);		Py_XDECREF(tb);		break;	}	case E_LINECONT:		msg = "unexpected character after line continuation character";		break;	default:		fprintf(stderr, "error=%d\n", err->error);		msg = "unknown parsing error";		break;	}	v = Py_BuildValue("(ziiz)", err->filename,			  err->lineno, err->offset, err->text);	if (err->text != NULL) {		PyObject_FREE(err->text);		err->text = NULL;	}	w = NULL;	if (v != NULL)		w = Py_BuildValue("(sO)", msg, v);	Py_XDECREF(u);	Py_XDECREF(v);	PyErr_SetObject(errtype, w);	Py_XDECREF(w);} /* Print fatal error message and abort */ voidPy_FatalError(const char *msg){	fprintf(stderr, "Fatal Python error: %s\n", msg);#ifdef MS_WINDOWS	OutputDebugString("Fatal Python error: ");	OutputDebugString(msg);	OutputDebugString("\n");#ifdef _DEBUG	DebugBreak();#endif#endif /* MS_WINDOWS */	abort();} /* Clean up and exit */ #ifdef WITH_THREAD#include "pythread.h"#endif #define NEXITFUNCS 32static void (*exitfuncs[NEXITFUNCS])(void);static int nexitfuncs = 0; int Py_AtExit(void (*func)(void)){	if (nexitfuncs >= NEXITFUNCS)		return -1;	exitfuncs[nexitfuncs++] = func;	return 0;} static voidcall_sys_exitfunc(void){	PyObject *exitfunc = PySys_GetObject("exitfunc"); 	if (exitfunc) {		PyObject *res;		Py_INCREF(exitfunc);		PySys_SetObject("exitfunc", (PyObject *)NULL);		res = PyEval_CallObject(exitfunc, (PyObject *)NULL);		if (res == NULL) {			if (!PyErr_ExceptionMatches(PyExc_SystemExit)) {				PySys_WriteStderr("Error in sys.exitfunc:\n");			}			PyErr_Print();		}		Py_DECREF(exitfunc);	} 	if (Py_FlushLine())		PyErr_Clear();} static voidcall_ll_exitfuncs(void){	while (nexitfuncs > 0)		(*exitfuncs[--nexitfuncs])(); 	fflush(stdout);	fflush(stderr);} voidPy_Exit(int sts){	Py_Finalize(); 	exit(sts);} static voidinitsigs(void){#ifdef SIGPIPE	PyOS_setsig(SIGPIPE, SIG_IGN);#endif#ifdef SIGXFZ	PyOS_setsig(SIGXFZ, SIG_IGN);#endif#ifdef SIGXFSZ	PyOS_setsig(SIGXFSZ, SIG_IGN);#endif	PyOS_InitInterrupts(); /* May imply initsignal() */}  /* * The file descriptor fd is considered ``interactive'' if either *   a) isatty(fd) is TRUE, or *   b) the -i flag was given, and the filename associated with *      the descriptor is NULL or "<stdin>" or "???". */intPy_FdIsInteractive(FILE *fp, const char *filename){	if (isatty((int)fileno(fp)))		return 1;	if (!Py_InteractiveFlag)		return 0;	return (filename == NULL) ||	       (strcmp(filename, "<stdin>") == 0) ||	       (strcmp(filename, "???") == 0);}  #if defined(USE_STACKCHECK)#if defined(WIN32) && defined(_MSC_VER) /* Stack checking for Microsoft C */ #include <malloc.h>#include <excpt.h> /* * Return non-zero when we run out of memory on the stack; zero otherwise. */intPyOS_CheckStack(void){	__try {		/* alloca throws a stack overflow exception if there's		   not enough space left on the stack */		alloca(PYOS_STACK_MARGIN * sizeof(void*));		return 0;	} __except (EXCEPTION_EXECUTE_HANDLER) {		/* just ignore all errors */	}	return 1;} #endif /* WIN32 && _MSC_VER */ /* Alternate implementations can be added here... */ #endif /* USE_STACKCHECK */  /* Wrappers around sigaction() or signal(). */ PyOS_sighandler_tPyOS_getsig(int sig){#ifdef HAVE_SIGACTION	struct sigaction context;	if (sigaction(sig, NULL, &context) == -1)		return SIG_ERR;	return context.sa_handler;#else	PyOS_sighandler_t handler;/* Special signal handling for the secure CRT in Visual Studio 2005 */#if defined(_MSC_VER) && _MSC_VER >= 1400	switch (sig) {	/* Only these signals are valid */	case SIGINT:	case SIGILL:	case SIGFPE:	case SIGSEGV:	case SIGTERM:	case SIGBREAK:	case SIGABRT:		break;	/* Don't call signal() with other values or it will assert */	default:		return SIG_ERR;	}#endif /* _MSC_VER && _MSC_VER >= 1400 */	handler = signal(sig, SIG_IGN);	if (handler != SIG_ERR)		signal(sig, handler);	return handler;#endif} PyOS_sighandler_tPyOS_setsig(int sig, PyOS_sighandler_t handler){#ifdef HAVE_SIGACTION	struct sigaction context, ocontext;	context.sa_handler = handler;	sigemptyset(&context.sa_mask);	context.sa_flags = 0;	if (sigaction(sig, &context, &ocontext) == -1)		return SIG_ERR;	return ocontext.sa_handler;#else	PyOS_sighandler_t oldhandler;	oldhandler = signal(sig, handler);#ifdef HAVE_SIGINTERRUPT	siginterrupt(sig, 1);#endif	return oldhandler;#endif} /* Deprecated C API functions still provided for binary compatiblity */ #undef PyParser_SimpleParseFilePyAPI_FUNC(node *)PyParser_SimpleParseFile(FILE *fp, const char *filename, int start){	return PyParser_SimpleParseFileFlags(fp, filename, start, 0);} #undef PyParser_SimpleParseStringPyAPI_FUNC(node *)PyParser_SimpleParseString(const char *str, int start){	return PyParser_SimpleParseStringFlags(str, start, 0);} #undef PyRun_AnyFilePyAPI_FUNC(int)PyRun_AnyFile(FILE *fp, const char *name){	return PyRun_AnyFileExFlags(fp, name, 0, NULL);} #undef PyRun_AnyFileExPyAPI_FUNC(int)PyRun_AnyFileEx(FILE *fp, const char *name, int closeit){	return PyRun_AnyFileExFlags(fp, name, closeit, NULL);} #undef PyRun_AnyFileFlagsPyAPI_FUNC(int)PyRun_AnyFileFlags(FILE *fp, const char *name, PyCompilerFlags *flags){	return PyRun_AnyFileExFlags(fp, name, 0, flags);} #undef PyRun_FilePyAPI_FUNC(PyObject *)PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l){        return PyRun_FileExFlags(fp, p, s, g, l, 0, NULL);} #undef PyRun_FileExPyAPI_FUNC(PyObject *)PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c){        return PyRun_FileExFlags(fp, p, s, g, l, c, NULL);} #undef PyRun_FileFlagsPyAPI_FUNC(PyObject *)PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l,		PyCompilerFlags *flags){        return PyRun_FileExFlags(fp, p, s, g, l, 0, flags);} #undef PyRun_SimpleFilePyAPI_FUNC(int)PyRun_SimpleFile(FILE *f, const char *p){	return PyRun_SimpleFileExFlags(f, p, 0, NULL);} #undef PyRun_SimpleFileExPyAPI_FUNC(int)PyRun_SimpleFileEx(FILE *f, const char *p, int c){	return PyRun_SimpleFileExFlags(f, p, c, NULL);}  #undef PyRun_StringPyAPI_FUNC(PyObject *)PyRun_String(const char *str, int s, PyObject *g, PyObject *l){	return PyRun_StringFlags(str, s, g, l, NULL);} #undef PyRun_SimpleStringPyAPI_FUNC(int)PyRun_SimpleString(const char *s){	return PyRun_SimpleStringFlags(s, NULL);} #undef Py_CompileStringPyAPI_FUNC(PyObject *)Py_CompileString(const char *str, const char *p, int s){	return Py_CompileStringFlags(str, p, s, NULL);} #undef PyRun_InteractiveOnePyAPI_FUNC(int)PyRun_InteractiveOne(FILE *f, const char *p){	return PyRun_InteractiveOneFlags(f, p, NULL);} #undef PyRun_InteractiveLoopPyAPI_FUNC(int)PyRun_InteractiveLoop(FILE *f, const char *p){	return PyRun_InteractiveLoopFlags(f, p, NULL);} #ifdef __cplusplus}#endif 

Lines 1501–1857 of 1857. Previous lines