From 456458ab8d094a4213976e89fbccf59e0c3aaa2d Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Mon, 7 Jun 2010 11:06:45 -0700 Subject: [PATCH] Another large integer literal fix (indexing). --- Cython/Compiler/ExprNodes.py | 4 ++++ tests/run/index.pyx | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 4f0129fa..cdf26701 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -18,6 +18,7 @@ from Builtin import list_type, tuple_type, set_type, dict_type, \ import Builtin import Symtab import Options +from Cython import Utils from Annotate import AnnotationItem from Cython.Debugging import print_call_chain @@ -1945,6 +1946,9 @@ class IndexNode(ExprNode): self.type = PyrexTypes.error_type return + if isinstance(self.index, IntNode) and Utils.long_literal(self.index.value): + self.index = self.index.coerce_to_pyobject(env) + # Handle the case where base is a literal char* (and we expect a string, not an int) if isinstance(self.base, BytesNode): self.base = self.base.coerce_to_pyobject(env) diff --git a/tests/run/index.pyx b/tests/run/index.pyx index 2e74c124..f829095b 100644 --- a/tests/run/index.pyx +++ b/tests/run/index.pyx @@ -129,6 +129,7 @@ def test_boundscheck(list L, tuple t, object o, unsigned long ix): def large_literal_index(object o): """ - >>> large_literal_index({1000000000000000000000000000000: "yes"}) + >>> large_literal_index({1000000000000000000000000000000: True}) + True """ return o[1000000000000000000000000000000] -- 2.26.2