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
d1170ab8
Commit
d1170ab8
authored
Nov 12, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix compiler crash in Py3 on negative Py2 octal integer literals (e.g. -012)
parent
2546c8c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
13 deletions
+30
-13
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-1
tests/run/int_literals.pyx
tests/run/int_literals.pyx
+29
-12
No files found.
Cython/Compiler/ExprNodes.py
View file @
d1170ab8
...
...
@@ -5005,7 +5005,7 @@ def unop_node(pos, operator, operand):
# Construct unnop node of appropriate class for
# given operator.
if
isinstance
(
operand
,
IntNode
)
and
operator
==
'-'
:
return
IntNode
(
pos
=
operand
.
pos
,
value
=
str
(
-
int
(
operand
.
value
,
0
)))
return
IntNode
(
pos
=
operand
.
pos
,
value
=
str
(
-
Utils
.
str_to_number
(
operand
.
value
)))
elif
isinstance
(
operand
,
UnopNode
)
and
operand
.
operator
==
operator
:
warning
(
pos
,
"Python has no increment/decrement operator: %s%sx = %s(%sx) = x"
%
((
operator
,)
*
4
),
5
)
return
unop_node_classes
[
operator
](
pos
,
...
...
tests/run/int_literals.pyx
View file @
d1170ab8
...
...
@@ -59,50 +59,67 @@ def c_long_types():
def
c_oct
():
"""
>>> c_oct()
(1, 17, 63)
(1,
-
17, 63)
"""
cdef
int
a
=
0o01
cdef
int
b
=
0o21
cdef
int
b
=
-
0o21
cdef
int
c
=
0o77
return
a
,
b
,
c
def
c_oct_py2_legacy
():
"""
>>> c_oct_py2_legacy()
(1, -17, 63)
"""
cdef
int
a
=
001
cdef
int
b
=
-
021
cdef
int
c
=
077
return
a
,
b
,
c
def
py_oct
():
"""
>>> py_oct()
(1, 17, 63)
(1, -17, 63)
"""
return
0o01
,
-
0o21
,
0o77
def
py_oct_py2_legacy
():
"""
>>> py_oct_py2_legacy()
(1, -17, 63)
"""
return
0
o01
,
0o21
,
0o
77
return
0
01
,
-
021
,
0
77
def
c_hex
():
"""
>>> c_hex()
(1, 33, 255)
(1,
-
33, 255)
"""
cdef
int
a
=
0x01
cdef
int
b
=
0x21
cdef
int
b
=
-
0x21
cdef
int
c
=
0xFF
return
a
,
b
,
c
def
py_hex
():
"""
>>> py_hex()
(1, 33, 255)
(1,
-
33, 255)
"""
return
0x01
,
0x21
,
0xFF
return
0x01
,
-
0x21
,
0xFF
def
c_bin
():
"""
>>> c_bin()
(1, 2, 15)
(1,
-
2, 15)
"""
cdef
int
a
=
0b01
cdef
int
b
=
0b10
cdef
int
b
=
-
0b10
cdef
int
c
=
0b1111
return
a
,
b
,
c
def
py_bin
():
"""
>>> py_bin()
(1, 2, 15)
(1,
-
2, 15)
"""
return
0b01
,
0b10
,
0b1111
return
0b01
,
-
0b10
,
0b1111
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