Commit d4d5dc49 authored by Stefan Behnel's avatar Stefan Behnel

fix for negative compile time int constants

parent 85021a88
...@@ -2741,7 +2741,7 @@ def unop_node(pos, operator, operand): ...@@ -2741,7 +2741,7 @@ 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 = -int(operand.value)) return IntNode(pos = operand.pos, value = str(-int(operand.value, 0)))
elif isinstance(operand, UnopNode) and operand.operator == operator: elif isinstance(operand, UnopNode) and operand.operator == operator:
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,
......
__doc__ = """ __doc__ = """
>>> c() >>> c()
120 120
>>> i0() == -1
True
>>> i1() == 42 >>> i1() == 42
True True
>>> i2() == 0x42 >>> i2() == 0x42
True True
>>> i3() == 042 >>> i3() == 042
True True
>>> i4() == -0x42
True
>>> l() >>> l()
666 666
>>> f() >>> f()
...@@ -27,9 +31,11 @@ DEF TUPLE = (1, 2, "buckle my shoe") ...@@ -27,9 +31,11 @@ DEF TUPLE = (1, 2, "buckle my shoe")
DEF TRUE_FALSE = (True, False) DEF TRUE_FALSE = (True, False)
DEF CHAR = c'x' DEF CHAR = c'x'
DEF INT0 = -1
DEF INT1 = 42 DEF INT1 = 42
DEF INT2 = 0x42 DEF INT2 = 0x42
DEF INT3 = 042 DEF INT3 = 042
DEF INT4 = -0x42
DEF LONG = 666L DEF LONG = 666L
DEF FLOAT = 12.5 DEF FLOAT = 12.5
DEF STR = "spam" DEF STR = "spam"
...@@ -43,6 +49,11 @@ def c(): ...@@ -43,6 +49,11 @@ def c():
c = CHAR c = CHAR
return c return c
def i0():
cdef int i
i = INT0
return i
def i1(): def i1():
cdef int i cdef int i
i = INT1 i = INT1
...@@ -58,6 +69,11 @@ def i3(): ...@@ -58,6 +69,11 @@ def i3():
i = INT3 i = INT3
return i return i
def i4():
cdef int i
i = INT4
return i
def l(): def l():
cdef long l cdef long l
l = LONG l = LONG
......
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