Skip to content

Commit c2f665e

Browse files
committed
don't put runtime values in array initializer for C89 compliance (closes python#20588)
1 parent f0560d9 commit c2f665e

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ What's New in Python 3.3.5 release candidate 1?
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #20588: Make Python-ast.c C89 compliant.
14+
1315
- Issue #20437: Fixed 21 potential bugs when deleting objects references.
1416

1517
- Issue #20538: UTF-7 incremental decoder produced inconsistant string when

Parser/asdl_c.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,10 +1150,14 @@ class PartingShots(StaticVisitor):
11501150
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
11511151
{
11521152
mod_ty res;
1153-
PyObject *req_type[] = {(PyObject*)Module_type, (PyObject*)Expression_type,
1154-
(PyObject*)Interactive_type};
1153+
PyObject *req_type[3];
11551154
char *req_name[] = {"Module", "Expression", "Interactive"};
11561155
int isinstance;
1156+
1157+
req_type[0] = (PyObject*)Module_type;
1158+
req_type[1] = (PyObject*)Expression_type;
1159+
req_type[2] = (PyObject*)Interactive_type;
1160+
11571161
assert(0 <= mode && mode <= 2);
11581162
11591163
init_types();

Python/Python-ast.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6957,10 +6957,14 @@ PyObject* PyAST_mod2obj(mod_ty t)
69576957
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
69586958
{
69596959
mod_ty res;
6960-
PyObject *req_type[] = {(PyObject*)Module_type, (PyObject*)Expression_type,
6961-
(PyObject*)Interactive_type};
6960+
PyObject *req_type[3];
69626961
char *req_name[] = {"Module", "Expression", "Interactive"};
69636962
int isinstance;
6963+
6964+
req_type[0] = (PyObject*)Module_type;
6965+
req_type[1] = (PyObject*)Expression_type;
6966+
req_type[2] = (PyObject*)Interactive_type;
6967+
69646968
assert(0 <= mode && mode <= 2);
69656969

69666970
init_types();

0 commit comments

Comments
 (0)