Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7979265

Browse files
committed
Convert all internal errors from Exception to SystemError
Remove an abort() and let a SystemError be raised.
1 parent daae616 commit 7979265

1 file changed

Lines changed: 17 additions & 19 deletions

File tree

Python/ast.c

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ ast_for_augassign(const node *n)
448448
else
449449
return Mult;
450450
default:
451-
PyErr_Format(PyExc_Exception, "invalid augassign: %s", STR(n));
451+
PyErr_Format(PyExc_SystemError, "invalid augassign: %s", STR(n));
452452
return 0;
453453
}
454454
}
@@ -481,7 +481,7 @@ ast_for_comp_op(const node *n)
481481
if (strcmp(STR(n), "is") == 0)
482482
return Is;
483483
default:
484-
PyErr_Format(PyExc_Exception, "invalid comp_op: %s",
484+
PyErr_Format(PyExc_SystemError, "invalid comp_op: %s",
485485
STR(n));
486486
return 0;
487487
}
@@ -495,12 +495,12 @@ ast_for_comp_op(const node *n)
495495
if (strcmp(STR(CHILD(n, 0)), "is") == 0)
496496
return IsNot;
497497
default:
498-
PyErr_Format(PyExc_Exception, "invalid comp_op: %s %s",
498+
PyErr_Format(PyExc_SystemError, "invalid comp_op: %s %s",
499499
STR(CHILD(n, 0)), STR(CHILD(n, 1)));
500500
return 0;
501501
}
502502
}
503-
PyErr_Format(PyExc_Exception, "invalid comp_op: has %d children",
503+
PyErr_Format(PyExc_SystemError, "invalid comp_op: has %d children",
504504
NCH(n));
505505
return 0;
506506
}
@@ -669,7 +669,7 @@ ast_for_arguments(struct compiling *c, const node *n)
669669
i += 3;
670670
break;
671671
default:
672-
PyErr_Format(PyExc_Exception,
672+
PyErr_Format(PyExc_SystemError,
673673
"unexpected node in varargslist: %d @ %d",
674674
TYPE(ch), i);
675675
goto error;
@@ -1309,8 +1309,7 @@ ast_for_atom(struct compiling *c, const node *n)
13091309
return Repr(expression, LINENO(n));
13101310
}
13111311
default:
1312-
PyErr_Format(PyExc_Exception, "unhandled atom %d",
1313-
TYPE(ch));
1312+
PyErr_Format(PyExc_SystemError, "unhandled atom %d", TYPE(ch));
13141313
return NULL;
13151314
}
13161315
}
@@ -1680,8 +1679,7 @@ ast_for_expr(struct compiling *c, const node *n)
16801679
case power:
16811680
return ast_for_power(c, n);
16821681
default:
1683-
abort();
1684-
PyErr_Format(PyExc_Exception, "unhandled expr: %d", TYPE(n));
1682+
PyErr_Format(PyExc_SystemError, "unhandled expr: %d", TYPE(n));
16851683
return NULL;
16861684
}
16871685
/* should never get here */
@@ -2131,7 +2129,7 @@ ast_for_flow_stmt(struct compiling *c, const node *n)
21312129
return Raise(expr1, expr2, expr3, LINENO(n));
21322130
}
21332131
default:
2134-
PyErr_Format(PyExc_Exception,
2132+
PyErr_Format(PyExc_SystemError,
21352133
"unexpected flow_stmt: %d", TYPE(ch));
21362134
return NULL;
21372135
}
@@ -2202,7 +2200,7 @@ alias_for_import_name(const node *n)
22022200
case STAR:
22032201
return alias(PyString_InternFromString("*"), NULL);
22042202
default:
2205-
PyErr_Format(PyExc_Exception,
2203+
PyErr_Format(PyExc_SystemError,
22062204
"unexpected import name: %d", TYPE(n));
22072205
return NULL;
22082206
}
@@ -2304,7 +2302,7 @@ ast_for_import_stmt(struct compiling *c, const node *n)
23042302
free_alias(mod);
23052303
return import;
23062304
}
2307-
PyErr_Format(PyExc_Exception,
2305+
PyErr_Format(PyExc_SystemError,
23082306
"unknown import statement: starts with command '%s'",
23092307
STR(CHILD(n, 0)));
23102308
return NULL;
@@ -2339,7 +2337,7 @@ ast_for_exec_stmt(struct compiling *c, const node *n)
23392337
expr_ty expr1, globals = NULL, locals = NULL;
23402338
int n_children = NCH(n);
23412339
if (n_children != 2 && n_children != 4 && n_children != 6) {
2342-
PyErr_Format(PyExc_Exception,
2340+
PyErr_Format(PyExc_SystemError,
23432341
"poorly formed 'exec' statement: %d parts to statement",
23442342
n_children);
23452343
return NULL;
@@ -2387,7 +2385,7 @@ ast_for_assert_stmt(struct compiling *c, const node *n)
23872385

23882386
return Assert(expr1, expr2, LINENO(n));
23892387
}
2390-
PyErr_Format(PyExc_Exception,
2388+
PyErr_Format(PyExc_SystemError,
23912389
"improper number of parts to 'assert' statement: %d",
23922390
NCH(n));
23932391
return NULL;
@@ -2574,7 +2572,7 @@ ast_for_if_stmt(struct compiling *c, const node *n)
25742572
orelse, LINENO(n));
25752573
}
25762574
else {
2577-
PyErr_Format(PyExc_Exception,
2575+
PyErr_Format(PyExc_SystemError,
25782576
"unexpected token in 'if' statement: %s", s);
25792577
return NULL;
25802578
}
@@ -2615,7 +2613,7 @@ ast_for_while_stmt(struct compiling *c, const node *n)
26152613
return While(expression, seq1, seq2, LINENO(n));
26162614
}
26172615
else {
2618-
PyErr_Format(PyExc_Exception,
2616+
PyErr_Format(PyExc_SystemError,
26192617
"wrong number of tokens for 'while' statement: %d",
26202618
NCH(n));
26212619
return NULL;
@@ -2702,7 +2700,7 @@ ast_for_except_clause(struct compiling *c, const node *exc, node *body)
27022700
return excepthandler(expression, e, suite_seq);
27032701
}
27042702
else {
2705-
PyErr_Format(PyExc_Exception,
2703+
PyErr_Format(PyExc_SystemError,
27062704
"wrong number of children for 'except' clause: %d",
27072705
NCH(exc));
27082706
return NULL;
@@ -2847,7 +2845,7 @@ ast_for_stmt(struct compiling *c, const node *n)
28472845
case assert_stmt:
28482846
return ast_for_assert_stmt(c, n);
28492847
default:
2850-
PyErr_Format(PyExc_Exception,
2848+
PyErr_Format(PyExc_SystemError,
28512849
"unhandled small_stmt: TYPE=%d NCH=%d\n",
28522850
TYPE(n), NCH(n));
28532851
return NULL;
@@ -2873,7 +2871,7 @@ ast_for_stmt(struct compiling *c, const node *n)
28732871
case classdef:
28742872
return ast_for_classdef(c, ch);
28752873
default:
2876-
PyErr_Format(PyExc_Exception,
2874+
PyErr_Format(PyExc_SystemError,
28772875
"unhandled small_stmt: TYPE=%d NCH=%d\n",
28782876
TYPE(n), NCH(n));
28792877
return NULL;

0 commit comments

Comments
 (0)