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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
3173319b
Commit
3173319b
authored
May 24, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow longer int literals on 64-bit machines.
parent
9d5aaeab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+3
-1
tests/run/int_literals.pyx
tests/run/int_literals.pyx
+10
-0
No files found.
Cython/Compiler/Code.py
View file @
3173319b
...
...
@@ -542,7 +542,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:
...
...
@@ -722,6 +722,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']
...
...
tests/run/int_literals.pyx
View file @
3173319b
...
...
@@ -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
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