Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
371b92f2
Commit
371b92f2
authored
May 26, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
merged in latest cython-devel
parents
0ca78ef8
d8952731
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
5 deletions
+20
-5
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+3
-1
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+7
-4
tests/run/int_literals.pyx
tests/run/int_literals.pyx
+10
-0
No files found.
Cython/Compiler/Code.py
View file @
371b92f2
...
@@ -537,7 +537,7 @@ class GlobalState(object):
...
@@ -537,7 +537,7 @@ class GlobalState(object):
# constant handling at code generation time
# constant handling at code generation time
def get_int_const(self, str_value, longness=False):
def get_int_const(self, str_value, longness=False):
longness = bool(longness
or Utils.long_literal(str_value)
)
longness = bool(longness)
try:
try:
c = self.int_const_index[(str_value, longness)]
c = self.int_const_index[(str_value, longness)]
except KeyError:
except KeyError:
...
@@ -717,6 +717,8 @@ class GlobalState(object):
...
@@ -717,6 +717,8 @@ class GlobalState(object):
decls_writer.putln("
static
PyObject
*%
s
;
" % cname)
decls_writer.putln("
static
PyObject
*%
s
;
" % cname)
if longness:
if longness:
function = '%s = PyLong_FromString((char *)"
%
s
", 0, 0); %s;'
function = '%s = PyLong_FromString((char *)"
%
s
", 0, 0); %s;'
elif Utils.long_literal(value):
function = '%s = PyInt_FromString((char *)"
%
s
", 0, 0); %s;'
else:
else:
function = "
%
s
=
PyInt_FromLong
(
%
s
);
%
s
;
"
function = "
%
s
=
PyInt_FromLong
(
%
s
);
%
s
;
"
init_globals = self.parts['init_globals']
init_globals = self.parts['init_globals']
...
...
Cython/Compiler/Parsing.py
View file @
371b92f2
...
@@ -1308,7 +1308,7 @@ def p_for_bounds(s, allow_testlist=True):
...
@@ -1308,7 +1308,7 @@ def p_for_bounds(s, allow_testlist=True):
s
.
next
()
s
.
next
()
iterator
=
p_for_iterator
(
s
,
allow_testlist
)
iterator
=
p_for_iterator
(
s
,
allow_testlist
)
return
{
'target'
:
target
,
'iterator'
:
iterator
}
return
{
'target'
:
target
,
'iterator'
:
iterator
}
el
s
e
:
el
if
not
s
.
in_python_fil
e
:
if
s
.
sy
==
'from'
:
if
s
.
sy
==
'from'
:
s
.
next
()
s
.
next
()
bound1
=
p_bit_expr
(
s
)
bound1
=
p_bit_expr
(
s
)
...
@@ -1340,6 +1340,9 @@ def p_for_bounds(s, allow_testlist=True):
...
@@ -1340,6 +1340,9 @@ def p_for_bounds(s, allow_testlist=True):
'relation2'
:
rel2
,
'relation2'
:
rel2
,
'bound2'
:
bound2
,
'bound2'
:
bound2
,
'step'
:
step
}
'step'
:
step
}
else
:
s
.
expect
(
'in'
)
return
{}
def
p_for_from_relation
(
s
):
def
p_for_from_relation
(
s
):
if
s
.
sy
in
inequality_relations
:
if
s
.
sy
in
inequality_relations
:
...
@@ -1641,7 +1644,7 @@ def p_statement(s, ctx, first_statement = 0):
...
@@ -1641,7 +1644,7 @@ def p_statement(s, ctx, first_statement = 0):
return
node
return
node
else
:
else
:
if
ctx
.
api
:
if
ctx
.
api
:
error
(
s
.
pos
,
"'api' not allowed with this statement"
)
s
.
error
(
"'api' not allowed with this statement"
)
elif
s
.
sy
==
'def'
:
elif
s
.
sy
==
'def'
:
# def statements aren't allowed in pxd files, except
# def statements aren't allowed in pxd files, except
# as part of a cdef class
# as part of a cdef class
...
@@ -1704,7 +1707,7 @@ def p_suite(s, ctx = Ctx(), with_doc = 0, with_pseudo_doc = 0):
...
@@ -1704,7 +1707,7 @@ def p_suite(s, ctx = Ctx(), with_doc = 0, with_pseudo_doc = 0):
s
.
expect_dedent
()
s
.
expect_dedent
()
else
:
else
:
if
ctx
.
api
:
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'
):
if
ctx
.
level
in
(
'module'
,
'class'
,
'function'
,
'other'
):
body
=
p_simple_statement_list
(
s
,
ctx
)
body
=
p_simple_statement_list
(
s
,
ctx
)
else
:
else
:
...
@@ -2428,7 +2431,7 @@ def p_c_func_or_var_declaration(s, pos, ctx):
...
@@ -2428,7 +2431,7 @@ def p_c_func_or_var_declaration(s, pos, ctx):
overridable
=
ctx
.
overridable
)
overridable
=
ctx
.
overridable
)
else
:
else
:
#if api:
#if api:
#
error(s.pos,
"'api' not allowed with variable declaration")
#
s.error(
"'api' not allowed with variable declaration")
declarators
=
[
declarator
]
declarators
=
[
declarator
]
while
s
.
sy
==
','
:
while
s
.
sy
==
','
:
s
.
next
()
s
.
next
()
...
...
tests/run/int_literals.pyx
View file @
371b92f2
...
@@ -25,3 +25,13 @@ def c_longs():
...
@@ -25,3 +25,13 @@ def c_longs():
def
py_longs
():
def
py_longs
():
return
1
,
1L
,
100000000000000000000000000000000
,
-
100000000000000000000000000000000
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment