Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
6ec6ab02
Kaydet (Commit)
6ec6ab02
authored
Tem 09, 2006
tarafından
Neil Schemenauer
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix SF bug 1441486: bad unary minus folding in compiler.
üst
0e07b60a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
20 deletions
+60
-20
test_compile.py
Lib/test/test_compile.py
+4
-0
NEWS
Misc/NEWS
+3
-0
ast.c
Python/ast.c
+53
-20
No files found.
Lib/test/test_compile.py
Dosyayı görüntüle @
6ec6ab02
...
@@ -211,6 +211,10 @@ if 1:
...
@@ -211,6 +211,10 @@ if 1:
self
.
assertEqual
(
eval
(
"-"
+
all_one_bits
),
-
18446744073709551615L
)
self
.
assertEqual
(
eval
(
"-"
+
all_one_bits
),
-
18446744073709551615L
)
else
:
else
:
self
.
fail
(
"How many bits *does* this machine have???"
)
self
.
fail
(
"How many bits *does* this machine have???"
)
# Verify treatment of contant folding on -(sys.maxint+1)
# i.e. -2147483648 on 32 bit platforms. Should return int, not long.
self
.
assertTrue
(
isinstance
(
eval
(
"
%
s"
%
(
-
sys
.
maxint
-
1
)),
int
))
self
.
assertTrue
(
isinstance
(
eval
(
"
%
s"
%
(
-
sys
.
maxint
-
2
)),
long
))
def
test_sequence_unpacking_error
(
self
):
def
test_sequence_unpacking_error
(
self
):
# Verify sequence packing/unpacking with "or". SF bug #757818
# Verify sequence packing/unpacking with "or". SF bug #757818
...
...
Misc/NEWS
Dosyayı görüntüle @
6ec6ab02
...
@@ -12,6 +12,9 @@ What's New in Python 2.5 beta 2?
...
@@ -12,6 +12,9 @@ What's New in Python 2.5 beta 2?
Core and builtins
Core and builtins
-----------------
-----------------
- Bug #1441486: The literal representation of -(sys.maxint - 1)
again evaluates to a int object, not a long.
- Bug #1501934: The scope of global variables that are locally assigned
- Bug #1501934: The scope of global variables that are locally assigned
using augmented assignment is now correctly determined.
using augmented assignment is now correctly determined.
...
...
Python/ast.c
Dosyayı görüntüle @
6ec6ab02
...
@@ -1483,6 +1483,57 @@ ast_for_trailer(struct compiling *c, const node *n, expr_ty left_expr)
...
@@ -1483,6 +1483,57 @@ ast_for_trailer(struct compiling *c, const node *n, expr_ty left_expr)
}
}
}
}
static
expr_ty
ast_for_factor
(
struct
compiling
*
c
,
const
node
*
n
)
{
node
*
pfactor
,
*
ppower
,
*
patom
,
*
pnum
;
expr_ty
expression
;
/* If the unary - operator is applied to a constant, don't generate
a UNARY_NEGATIVE opcode. Just store the approriate value as a
constant. The peephole optimizer already does something like
this but it doesn't handle the case where the constant is
(sys.maxint - 1). In that case, we want a PyIntObject, not a
PyLongObject.
*/
if
(
TYPE
(
CHILD
(
n
,
0
))
==
MINUS
&&
NCH
(
n
)
==
2
&&
TYPE
((
pfactor
=
CHILD
(
n
,
1
)))
==
factor
&&
NCH
(
pfactor
)
==
1
&&
TYPE
((
ppower
=
CHILD
(
pfactor
,
0
)))
==
power
&&
NCH
(
ppower
)
==
1
&&
TYPE
((
patom
=
CHILD
(
ppower
,
0
)))
==
atom
&&
TYPE
((
pnum
=
CHILD
(
patom
,
0
)))
==
NUMBER
)
{
char
*
s
=
PyObject_MALLOC
(
strlen
(
STR
(
pnum
))
+
2
);
if
(
s
==
NULL
)
return
NULL
;
s
[
0
]
=
'-'
;
strcpy
(
s
+
1
,
STR
(
pnum
));
PyObject_FREE
(
STR
(
pnum
));
STR
(
pnum
)
=
s
;
return
ast_for_atom
(
c
,
patom
);
}
expression
=
ast_for_expr
(
c
,
CHILD
(
n
,
1
));
if
(
!
expression
)
return
NULL
;
switch
(
TYPE
(
CHILD
(
n
,
0
)))
{
case
PLUS
:
return
UnaryOp
(
UAdd
,
expression
,
LINENO
(
n
),
n
->
n_col_offset
,
c
->
c_arena
);
case
MINUS
:
return
UnaryOp
(
USub
,
expression
,
LINENO
(
n
),
n
->
n_col_offset
,
c
->
c_arena
);
case
TILDE
:
return
UnaryOp
(
Invert
,
expression
,
LINENO
(
n
),
n
->
n_col_offset
,
c
->
c_arena
);
}
PyErr_Format
(
PyExc_SystemError
,
"unhandled factor: %d"
,
TYPE
(
CHILD
(
n
,
0
)));
return
NULL
;
}
static
expr_ty
static
expr_ty
ast_for_power
(
struct
compiling
*
c
,
const
node
*
n
)
ast_for_power
(
struct
compiling
*
c
,
const
node
*
n
)
{
{
...
@@ -1662,30 +1713,12 @@ ast_for_expr(struct compiling *c, const node *n)
...
@@ -1662,30 +1713,12 @@ ast_for_expr(struct compiling *c, const node *n)
}
}
return
Yield
(
exp
,
LINENO
(
n
),
n
->
n_col_offset
,
c
->
c_arena
);
return
Yield
(
exp
,
LINENO
(
n
),
n
->
n_col_offset
,
c
->
c_arena
);
}
}
case
factor
:
{
case
factor
:
expr_ty
expression
;
if
(
NCH
(
n
)
==
1
)
{
if
(
NCH
(
n
)
==
1
)
{
n
=
CHILD
(
n
,
0
);
n
=
CHILD
(
n
,
0
);
goto
loop
;
goto
loop
;
}
}
return
ast_for_factor
(
c
,
n
);
expression
=
ast_for_expr
(
c
,
CHILD
(
n
,
1
));
if
(
!
expression
)
return
NULL
;
switch
(
TYPE
(
CHILD
(
n
,
0
)))
{
case
PLUS
:
return
UnaryOp
(
UAdd
,
expression
,
LINENO
(
n
),
n
->
n_col_offset
,
c
->
c_arena
);
case
MINUS
:
return
UnaryOp
(
USub
,
expression
,
LINENO
(
n
),
n
->
n_col_offset
,
c
->
c_arena
);
case
TILDE
:
return
UnaryOp
(
Invert
,
expression
,
LINENO
(
n
),
n
->
n_col_offset
,
c
->
c_arena
);
}
PyErr_Format
(
PyExc_SystemError
,
"unhandled factor: %d"
,
TYPE
(
CHILD
(
n
,
0
)));
break
;
}
case
power
:
case
power
:
return
ast_for_power
(
c
,
n
);
return
ast_for_power
(
c
,
n
);
default:
default:
...
...
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