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
23c084c9
Commit
23c084c9
authored
Nov 27, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
keep longness when folding negative integer constants
parent
fc08e8bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-1
tests/run/int_literals.pyx
tests/run/int_literals.pyx
+17
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
23c084c9
...
@@ -7317,7 +7317,8 @@ def unop_node(pos, operator, operand):
...
@@ -7317,7 +7317,8 @@ def unop_node(pos, operator, operand):
# Construct unnop node of appropriate class for
# Construct unnop node of appropriate class for
# given operator.
# given operator.
if
isinstance
(
operand
,
IntNode
)
and
operator
==
'-'
:
if
isinstance
(
operand
,
IntNode
)
and
operator
==
'-'
:
return
IntNode
(
pos
=
operand
.
pos
,
value
=
str
(
-
Utils
.
str_to_number
(
operand
.
value
)))
return
IntNode
(
pos
=
operand
.
pos
,
value
=
str
(
-
Utils
.
str_to_number
(
operand
.
value
)),
longness
=
operand
.
longness
,
unsigned
=
operand
.
unsigned
)
elif
isinstance
(
operand
,
UnopNode
)
and
operand
.
operator
==
operator
in
'+-'
:
elif
isinstance
(
operand
,
UnopNode
)
and
operand
.
operator
==
operator
in
'+-'
:
warning
(
pos
,
"Python has no increment/decrement operator: %s%sx == %s(%sx) == x"
%
((
operator
,)
*
4
),
5
)
warning
(
pos
,
"Python has no increment/decrement operator: %s%sx == %s(%sx) == x"
%
((
operator
,)
*
4
),
5
)
return
unop_node_classes
[
operator
](
pos
,
return
unop_node_classes
[
operator
](
pos
,
...
...
tests/run/int_literals.pyx
View file @
23c084c9
__doc__
=
u"""
__doc__
=
u"""
>>> c_longs()
>>> c_longs()
(1, 1L, -1L, 18446744073709551615L)
(1, 1L, -1L, 18446744073709551615L)
>>> negative_c_longs()
(-1, -9223285636854775809L)
>>> py_longs()
>>> py_longs()
(1, 1L, 100000000000000000000000000000000L, -100000000000000000000000000000000L)
(1, 1L, 100000000000000000000000000000000L, -100000000000000000000000000000000L)
...
@@ -18,14 +20,28 @@ import sys
...
@@ -18,14 +20,28 @@ import sys
if
sys
.
version_info
[
0
]
>=
3
:
if
sys
.
version_info
[
0
]
>=
3
:
__doc__
=
__doc__
.
replace
(
u'L'
,
u''
)
__doc__
=
__doc__
.
replace
(
u'L'
,
u''
)
@
cython
.
test_assert_path_exists
(
'//IntNode[@longness = "LL"]'
,
'//IntNode[@longness = "L"]'
,
)
@
cython
.
test_fail_if_path_exists
(
'//IntNode[@longness = ""]'
)
def
c_longs
():
def
c_longs
():
cdef
long
a
=
1L
cdef
long
a
=
1L
cdef
unsigned
long
ua
=
1
UL
cdef
unsigned
long
ua
=
1
UL
cdef
long
long
aa
=
0xFFFFFFFFFFFFFFFF
LL
cdef
long
long
aa
=
0xFFFFFFFFFFFFFFFF
LL
cdef
unsigned
long
long
uaa
=
0xFFFFFFFFFFFFFFFF
ULL
cdef
unsigned
long
long
uaa
=
0xFFFFFFFFFFFFFFFF
ULL
return
a
,
ua
,
aa
,
uaa
return
a
,
ua
,
aa
,
uaa
@
cython
.
test_assert_path_exists
(
'//IntNode[@longness = "LL"]'
,
'//IntNode[@longness = "L"]'
,
)
@
cython
.
test_fail_if_path_exists
(
'//IntNode[@longness = ""]'
)
def
negative_c_longs
():
cdef
long
a
=
-
1L
cdef
long
long
aa
=
-
9223285636854775809L
L
return
a
,
aa
def
py_longs
():
def
py_longs
():
return
1
,
1L
,
100000000000000000000000000000000
,
-
100000000000000000000000000000000
return
1
,
1L
,
100000000000000000000000000000000
,
-
100000000000000000000000000000000
...
...
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