mirror of
https://github.com/python/cpython.git
synced 2025-10-22 06:32:43 +00:00
err_clear: clear interpreter stack trace
This commit is contained in:
parent
13836d9e6d
commit
3a24181837
1 changed files with 7 additions and 40 deletions
|
@ -1,5 +1,5 @@
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
|
Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
|
||||||
Amsterdam, The Netherlands.
|
Amsterdam, The Netherlands.
|
||||||
|
|
||||||
All Rights Reserved
|
All Rights Reserved
|
||||||
|
@ -60,8 +60,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "errcode.h"
|
|
||||||
|
|
||||||
extern char *strerror PROTO((int));
|
extern char *strerror PROTO((int));
|
||||||
|
|
||||||
/* Last exception stored by err_setval() */
|
/* Last exception stored by err_setval() */
|
||||||
|
@ -100,10 +98,11 @@ err_setstr(exception, string)
|
||||||
XDECREF(value);
|
XDECREF(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
|
object *
|
||||||
err_occurred()
|
err_occurred()
|
||||||
{
|
{
|
||||||
return last_exception != NULL;
|
return last_exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -147,11 +146,10 @@ err_errno(exc)
|
||||||
object *exc;
|
object *exc;
|
||||||
{
|
{
|
||||||
object *v;
|
object *v;
|
||||||
if (errno == EINTR && intrcheck()) {
|
int i = errno;
|
||||||
err_set(KeyboardInterrupt);
|
if (i == EINTR && sigcheck())
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
v = mkvalue("(is)", i, strerror(i));
|
||||||
v = mkvalue("(is)", errno, strerror(errno));
|
|
||||||
if (v != NULL) {
|
if (v != NULL) {
|
||||||
err_setval(exc, v);
|
err_setval(exc, v);
|
||||||
DECREF(v);
|
DECREF(v);
|
||||||
|
@ -164,34 +162,3 @@ err_badcall()
|
||||||
{
|
{
|
||||||
err_setstr(SystemError, "bad argument to internal function");
|
err_setstr(SystemError, "bad argument to internal function");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the error appropriate to the given input error code (see errcode.h) */
|
|
||||||
|
|
||||||
void
|
|
||||||
err_input(err)
|
|
||||||
int err;
|
|
||||||
{
|
|
||||||
switch (err) {
|
|
||||||
case E_DONE:
|
|
||||||
case E_OK:
|
|
||||||
break;
|
|
||||||
case E_SYNTAX:
|
|
||||||
err_setstr(SyntaxError, "invalid syntax");
|
|
||||||
break;
|
|
||||||
case E_TOKEN:
|
|
||||||
err_setstr(SyntaxError, "invalid token");
|
|
||||||
break;
|
|
||||||
case E_INTR:
|
|
||||||
err_set(KeyboardInterrupt);
|
|
||||||
break;
|
|
||||||
case E_NOMEM:
|
|
||||||
err_nomem();
|
|
||||||
break;
|
|
||||||
case E_EOF:
|
|
||||||
err_setstr(SyntaxError, "unexpected EOF while parsing");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
err_setstr(SystemError, "unknown parsing error");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue