Lines Matching +full:hook +full:- +full:run +full:- +full:in +full:- +full:context
2 /* Top level execution of Python code (including in __main__) */
13 #include "Python-ast.h"
97 int show_ref_count = _PyInterpreterState_Get()->config.show_ref_count; in PyRun_InteractiveLoopFlags()
103 return -1; in PyRun_InteractiveLoopFlags()
122 if (ret == -1 && PyErr_Occurred()) { in PyRun_InteractiveLoopFlags()
129 err = -1; in PyRun_InteractiveLoopFlags()
156 if (flags->cf_flags & PyCF_DONT_IMPLY_DEDENT) in PARSER_FLAGS()
158 if (flags->cf_flags & PyCF_IGNORE_COOKIE) in PARSER_FLAGS()
160 if (flags->cf_flags & CO_FUTURE_BARRY_AS_BDFL) in PARSER_FLAGS()
162 if (flags->cf_flags & PyCF_TYPE_COMMENTS) in PARSER_FLAGS()
170 ((flags) ? ((((flags)->cf_flags & PyCF_DONT_IMPLY_DEDENT) ? \
172 | ((flags)->cf_flags & CO_FUTURE_WITH_STATEMENT ? \
192 return -1; in PyRun_InteractiveOneObjectEx()
237 return -1; in PyRun_InteractiveOneObjectEx()
251 return -1; in PyRun_InteractiveOneObjectEx()
256 return -1; in PyRun_InteractiveOneObjectEx()
262 return -1; in PyRun_InteractiveOneObjectEx()
275 if (res == -1) { in PyRun_InteractiveOneObject()
291 return -1; in PyRun_InteractiveOneFlags()
311 /* Read only two bytes of the magic. If the file was opened in in maybe_pyc_file()
316 /* Mess: In case of -x, the stream is NOT at its start now, in maybe_pyc_file()
319 and a x-platform nightmare. in maybe_pyc_file()
320 Unfortunately, we have no direct way to know whether -x in maybe_pyc_file()
322 stream position is not 0, we assume -x was specified, and in maybe_pyc_file()
325 don't work predictably x-platform for text-mode files). in maybe_pyc_file()
347 return -1; in set_main_loader()
349 bootstrap = PyObject_GetAttrString(interp->importlib, in set_main_loader()
357 return -1; in set_main_loader()
362 return -1; in set_main_loader()
365 result = -1; in set_main_loader()
377 int set_file_name = 0, ret = -1; in PyRun_SimpleFileExFlags()
382 return -1; in PyRun_SimpleFileExFlags()
402 ext = filename + len - (len > 4 ? 4 : 0); in PyRun_SimpleFileExFlags()
405 /* Try to run a pyc file. First, re-open in binary */ in PyRun_SimpleFileExFlags()
415 ret = -1; in PyRun_SimpleFileExFlags()
425 ret = -1; in PyRun_SimpleFileExFlags()
458 return -1; in PyRun_SimpleStringFlags()
463 return -1; in PyRun_SimpleStringFlags()
516 *offset = -1; in parse_syntax_error()
555 if (offset > 0 && (size_t)offset == strlen(text) && text[offset - 1] == '\n') in print_error_text()
556 offset--; in print_error_text()
559 if (nl == NULL || nl-text >= offset) in print_error_text()
561 offset -= (int)(nl+1-text); in print_error_text()
566 offset--; in print_error_text()
571 if (*text == '\0' || text[strlen(text)-1] != '\n') in print_error_text()
573 if (offset == -1) in print_error_text()
576 while (--offset > 0) in print_error_text()
585 int inspect = _PyInterpreterState_GET_UNSAFE()->config.inspect; in _Py_HandleSystemExit()
587 /* Don't exit if -i flag was given. This flag is set to 0 in _Py_HandleSystemExit()
607 /* The error code should be in the `code' attribute. */ in _Py_HandleSystemExit()
626 * in PyObject_Str that ensures it won't silently lose exception in _Py_HandleSystemExit()
641 /* Restore and clear the exception info, in order to properly decref in _Py_HandleSystemExit()
666 PyObject *exception, *v, *tb, *hook; in _PyErr_PrintEx() local
697 hook = _PySys_GetObjectId(&PyId_excepthook); in _PyErr_PrintEx()
698 if (PySys_Audit("sys.excepthook", "OOOO", hook ? hook : Py_None, in _PyErr_PrintEx()
704 _PyErr_WriteUnraisableMsg("in audit hook", NULL); in _PyErr_PrintEx()
706 if (hook) { in _PyErr_PrintEx()
713 result = _PyObject_FastCall(hook, stack, 3); in _PyErr_PrintEx()
732 PySys_WriteStderr("Error in sys.excepthook:\n"); in _PyErr_PrintEx()
781 err += PyFile_WriteString(Py_TYPE(value)->tp_name, f); in print_exception()
824 err = -1; in print_exception()
870 err = -1; in print_exception()
880 /* try to write a newline in any case */ in print_exception()
905 PyObject *cause, *context; in print_exception_recursive() local
910 if (value_id == NULL || PySet_Add(seen, value_id) == -1) in print_exception_recursive()
915 context = PyException_GetContext(value); in print_exception_recursive()
919 res = -1; in print_exception_recursive()
924 if (res == -1) in print_exception_recursive()
933 else if (context && in print_exception_recursive()
934 !((PyBaseExceptionObject *)value)->suppress_context) { in print_exception_recursive()
935 check_id = PyLong_FromVoidPtr(context); in print_exception_recursive()
937 res = -1; in print_exception_recursive()
942 if (res == -1) in print_exception_recursive()
946 f, context, seen); in print_exception_recursive()
951 Py_XDECREF(context); in print_exception_recursive()
1106 * We explicitly re-initialize _Py_UnhandledKeyboardInterrupt every eval in run_eval_code_obj()
1107 * _just in case_ someone is calling into an embedded Python where they in run_eval_code_obj()
1120 if (PyDict_SetItemString(globals, "__builtins__", interp->builtins) < 0) { in run_eval_code_obj()
1138 co = PyAST_CompileObject(mod, filename, flags, -1, arena); in run_mod()
1165 "Bad magic number in .pyc file"); in run_pyc_file()
1179 "Bad code object in .pyc file"); in run_pyc_file()
1186 flags->cf_flags |= (co->co_flags & PyCF_MASK); in run_pyc_file()
1209 if (flags && (flags->cf_flags & PyCF_ONLY_AST)) { in Py_CompileStringObject()
1232 /* For use in Py_LIMITED_API */
1249 cf->cf_flags |= PyCF_IGNORE_COOKIE; in _Py_SourceAsString()
1263 /* Copy to NUL-terminated buffer. */ in _Py_SourceAsString()
1340 if (flags && (flags->cf_flags & PyCF_ONLY_AST) && flags->cf_feature_version < 7) in PyParser_ASTFromStringObject()
1350 flags->cf_flags |= iflags & PyCF_MASK; in PyParser_ASTFromStringObject()
1394 flags->cf_flags |= iflags & PyCF_MASK; in PyParser_ASTFromFileObject()
1425 /* Simplified interface to parsefile -- return node or set exception */
1441 /* Simplified interface to parsestring -- return node or set exception */
1486 Py_CLEAR(err->filename); in err_free()
1497 int offset = err->offset; in err_input()
1500 switch (err->error) { in err_input()
1505 if (err->expected == INDENT) in err_input()
1507 else if (err->token == INDENT) in err_input()
1509 else if (err->token == DEDENT) in err_input()
1511 else if (err->expected == NOTEQUAL) { in err_input()
1524 msg = "EOF while scanning triple-quoted string literal"; in err_input()
1541 msg = "inconsistent use of tabs and spaces in indentation"; in err_input()
1570 msg = "invalid character in identifier"; in err_input()
1576 fprintf(stderr, "error=%d\n", err->error); in err_input()
1580 /* err->text may not be UTF-8 in case of decoding errors. in err_input()
1582 if (!err->text) { in err_input()
1586 errtext = PyUnicode_DecodeUTF8(err->text, err->offset, in err_input()
1589 Py_ssize_t len = strlen(err->text); in err_input()
1591 if (len != err->offset) { in err_input()
1593 errtext = PyUnicode_DecodeUTF8(err->text, len, in err_input()
1598 v = Py_BuildValue("(OiiN)", err->filename, in err_input()
1599 err->lineno, offset, errtext); in err_input()
1612 if (err->text != NULL) { in err_input()
1613 PyObject_FREE(err->text); in err_input()
1614 err->text = NULL; in err_input()
1628 * Return non-zero when we run out of memory on the stack; zero otherwise.
1748 return Py_CompileStringExFlags(str, p, s, NULL, -1); in Py_CompileString()
1756 return Py_CompileStringExFlags(str, p, s, flags, -1); in Py_CompileStringFlags()