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

Skip to content

Commit 6baa4c4

Browse files
committed
Whoops, fix build breakage. There were still a few uses of the bool type.
Remove the last few uses of bool/true/false.
1 parent 3591bbe commit 6baa4c4

4 files changed

Lines changed: 11 additions & 19 deletions

File tree

Include/asdl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ typedef PyObject * identifier;
55
typedef PyObject * string;
66
typedef PyObject * object;
77

8-
#ifndef __cplusplus
9-
typedef enum {false, true} bool;
10-
#endif
11-
128
/* It would be nice if the code generated by asdl_c.py was completely
139
independent of Python, but it is a goal the requires too much work
1410
at this stage. So, for example, I'll represent identifiers as

Python/Python-ast.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
/*
5-
__version__ 53873.
5+
__version__ 53956.
66
77
This module must be committed separately after each AST grammar change;
88
The __version__ number is set to the revision number of the commit
@@ -443,10 +443,6 @@ static PyObject* ast2obj_object(void *o)
443443
}
444444
#define ast2obj_identifier ast2obj_object
445445
#define ast2obj_string ast2obj_object
446-
static PyObject* ast2obj_bool(bool b)
447-
{
448-
return PyBool_FromLong(b);
449-
}
450446

451447
static PyObject* ast2obj_int(long b)
452448
{
@@ -3013,7 +3009,7 @@ init_ast(void)
30133009
if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return;
30143010
if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0)
30153011
return;
3016-
if (PyModule_AddStringConstant(m, "__version__", "53873") < 0)
3012+
if (PyModule_AddStringConstant(m, "__version__", "53956") < 0)
30173013
return;
30183014
if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return;
30193015
if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0)

Python/ast.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ ast_for_trailer(struct compiling *c, const node *n, expr_ty left_expr)
16601660
int j;
16611661
slice_ty slc;
16621662
expr_ty e;
1663-
bool simple = true;
1663+
int simple = 1;
16641664
asdl_seq *slices, *elts;
16651665
slices = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena);
16661666
if (!slices)
@@ -1670,7 +1670,7 @@ ast_for_trailer(struct compiling *c, const node *n, expr_ty left_expr)
16701670
if (!slc)
16711671
return NULL;
16721672
if (slc->kind != Index_kind)
1673-
simple = false;
1673+
simple = 0;
16741674
asdl_seq_SET(slices, j / 2, slc);
16751675
}
16761676
if (!simple) {

Python/compile.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ struct compiler_unit {
119119

120120
int u_firstlineno; /* the first lineno of the block */
121121
int u_lineno; /* the lineno for the current stmt */
122-
bool u_lineno_set; /* boolean to indicate whether instr
122+
int u_lineno_set; /* boolean to indicate whether instr
123123
has been generated with current lineno */
124124
};
125125

@@ -464,7 +464,7 @@ compiler_enter_scope(struct compiler *c, identifier name, void *key,
464464
u->u_nfblocks = 0;
465465
u->u_firstlineno = lineno;
466466
u->u_lineno = 0;
467-
u->u_lineno_set = false;
467+
u->u_lineno_set = 0;
468468
u->u_consts = PyDict_New();
469469
if (!u->u_consts) {
470470
compiler_unit_free(u);
@@ -643,7 +643,7 @@ compiler_set_lineno(struct compiler *c, int off)
643643
basicblock *b;
644644
if (c->u->u_lineno_set)
645645
return;
646-
c->u->u_lineno_set = true;
646+
c->u->u_lineno_set = 1;
647647
b = c->u->u_curblock;
648648
b->b_instr[off].i_lineno = c->u->u_lineno;
649649
}
@@ -1675,7 +1675,7 @@ compiler_for(struct compiler *c, stmt_ty s)
16751675
/* XXX(nnorwitz): is there a better way to handle this?
16761676
for loops are special, we want to be able to trace them
16771677
each time around, so we need to set an extra line number. */
1678-
c->u->u_lineno_set = false;
1678+
c->u->u_lineno_set = 0;
16791679
ADDOP_JREL(c, FOR_ITER, cleanup);
16801680
VISIT(c, expr, s->v.For.target);
16811681
VISIT_SEQ(c, stmt, s->v.For.body);
@@ -1898,7 +1898,7 @@ compiler_try_except(struct compiler *c, stmt_ty s)
18981898
s->v.TryExcept.handlers, i);
18991899
if (!handler->type && i < n-1)
19001900
return compiler_error(c, "default 'except:' must be last");
1901-
c->u->u_lineno_set = false;
1901+
c->u->u_lineno_set = 0;
19021902
c->u->u_lineno = handler->lineno;
19031903
except = compiler_new_block(c);
19041904
if (except == NULL)
@@ -2161,7 +2161,7 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s)
21612161

21622162
/* Always assign a lineno to the next instruction for a stmt. */
21632163
c->u->u_lineno = s->lineno;
2164-
c->u->u_lineno_set = false;
2164+
c->u->u_lineno_set = 0;
21652165

21662166
switch (s->kind) {
21672167
case FunctionDef_kind:
@@ -3015,7 +3015,7 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
30153015
*/
30163016
if (e->lineno > c->u->u_lineno) {
30173017
c->u->u_lineno = e->lineno;
3018-
c->u->u_lineno_set = false;
3018+
c->u->u_lineno_set = 0;
30193019
}
30203020
switch (e->kind) {
30213021
case BoolOp_kind:

0 commit comments

Comments
 (0)