From d48faaebb2d27b1a435d521b780ea058042a3620 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 14 Nov 2008 19:19:55 +0100 Subject: [PATCH] array size must be set as int, not numeric string --- Cython/Compiler/Nodes.py | 5 +++++ Cython/Compiler/PyrexTypes.py | 1 + 2 files changed, 6 insertions(+) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 99c455e7..56b69d8f 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -442,6 +442,11 @@ class CArrayDeclaratorNode(CDeclaratorNode): if not self.dimension.type.is_int: error(self.dimension.pos, "Array dimension not integer") size = self.dimension.result() + try: + size = int(size) + except ValueError: + # runtime constant? + pass else: size = None if not base_type.is_complete(): diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 70330959..281cf0ad 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -616,6 +616,7 @@ class CArrayType(CType): is_array = 1 def __init__(self, base_type, size): + assert size is None or isinstance(size, int), repr(size) self.base_type = base_type self.size = size if base_type is c_char_type: -- 2.26.2