Commit 371b92f2 authored by Stefan Behnel's avatar Stefan Behnel

merged in latest cython-devel

parents 0ca78ef8 d8952731
......@@ -537,7 +537,7 @@ class GlobalState(object):
# constant handling at code generation time
def get_int_const(self, str_value, longness=False):
longness = bool(longness or Utils.long_literal(str_value))
longness = bool(longness)
try:
c = self.int_const_index[(str_value, longness)]
except KeyError:
......@@ -717,6 +717,8 @@ class GlobalState(object):
decls_writer.putln("static PyObject *%s;" % cname)
if longness:
function = '%s = PyLong_FromString((char *)"%s", 0, 0); %s;'
elif Utils.long_literal(value):
function = '%s = PyInt_FromString((char *)"%s", 0, 0); %s;'
else:
function = "%s = PyInt_FromLong(%s); %s;"
init_globals = self.parts['init_globals']
......
......@@ -1308,7 +1308,7 @@ def p_for_bounds(s, allow_testlist=True):
s.next()
iterator = p_for_iterator(s, allow_testlist)
return { 'target': target, 'iterator': iterator }
else:
elif not s.in_python_file:
if s.sy == 'from':
s.next()
bound1 = p_bit_expr(s)
......@@ -1340,6 +1340,9 @@ def p_for_bounds(s, allow_testlist=True):
'relation2': rel2,
'bound2': bound2,
'step': step }
else:
s.expect('in')
return {}
def p_for_from_relation(s):
if s.sy in inequality_relations:
......@@ -1641,7 +1644,7 @@ def p_statement(s, ctx, first_statement = 0):
return node
else:
if ctx.api:
error(s.pos, "'api' not allowed with this statement")
s.error("'api' not allowed with this statement")
elif s.sy == 'def':
# def statements aren't allowed in pxd files, except
# as part of a cdef class
......@@ -1704,7 +1707,7 @@ def p_suite(s, ctx = Ctx(), with_doc = 0, with_pseudo_doc = 0):
s.expect_dedent()
else:
if ctx.api:
error(s.pos, "'api' not allowed with this statement")
s.error("'api' not allowed with this statement")
if ctx.level in ('module', 'class', 'function', 'other'):
body = p_simple_statement_list(s, ctx)
else:
......@@ -2428,7 +2431,7 @@ def p_c_func_or_var_declaration(s, pos, ctx):
overridable = ctx.overridable)
else:
#if api:
# error(s.pos, "'api' not allowed with variable declaration")
# s.error("'api' not allowed with variable declaration")
declarators = [declarator]
while s.sy == ',':
s.next()
......
......@@ -25,3 +25,13 @@ def c_longs():
def py_longs():
return 1, 1L, 100000000000000000000000000000000, -100000000000000000000000000000000
def large_literal():
"""
>>> type(large_literal()) is int
True
"""
if sys.version_info[0] >= 3 or sys.maxint > 0xFFFFFFFFFFFF:
return 0xFFFFFFFFFFFF
else:
return 0xFFFFFFF
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment