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
c4161623
Kaydet (Commit)
c4161623
authored
Haz 07, 2014
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
allow the keyword else immediately after (no space) an integer (closes #21642)
üst
024b2f52
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
5 deletions
+24
-5
test_grammar.py
Lib/test/test_grammar.py
+6
-0
NEWS
Misc/NEWS
+4
-0
tokenizer.c
Parser/tokenizer.c
+14
-5
No files found.
Lib/test/test_grammar.py
Dosyayı görüntüle @
c4161623
...
...
@@ -80,6 +80,12 @@ class TokenTests(unittest.TestCase):
x
=
.
3e14
x
=
3.1e4
def
test_float_exponent_tokenization
(
self
):
# See issue 21642.
self
.
assertEqual
(
1
if
1
else
0
,
1
)
self
.
assertEqual
(
1
if
0
else
0
,
0
)
self
.
assertRaises
(
SyntaxError
,
eval
,
"0 if 1Else 0"
)
def
test_string_literals
(
self
):
x
=
''
;
y
=
""
;
self
.
assertTrue
(
len
(
x
)
==
0
and
x
==
y
)
x
=
'
\'
'
;
y
=
"'"
;
self
.
assertTrue
(
len
(
x
)
==
1
and
x
==
y
and
ord
(
x
)
==
39
)
...
...
Misc/NEWS
Dosyayı görüntüle @
c4161623
...
...
@@ -10,6 +10,10 @@ Release date: XXXX-XX-XX
Core and Builtins
-----------------
- Issue #21642: If the conditional if-else expression, allow an integer written
with no space between itself and the ``else`` keyword (e.g. ``True if 42else
False``) to be valid syntax.
- Issue #21523: Fix over-pessimistic computation of the stack effect of
some opcodes in the compiler. This also fixes a quadratic compilation
time issue noticeable when compiling code with a large number of "and"
...
...
Parser/tokenizer.c
Dosyayı görüntüle @
c4161623
...
...
@@ -1597,15 +1597,24 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end)
}
while
(
isdigit
(
c
));
}
if
(
c
==
'e'
||
c
==
'E'
)
{
exponent:
int
e
;
exponent:
e
=
c
;
/* Exponent part */
c
=
tok_nextc
(
tok
);
if
(
c
==
'+'
||
c
==
'-'
)
if
(
c
==
'+'
||
c
==
'-'
)
{
c
=
tok_nextc
(
tok
);
if
(
!
isdigit
(
c
))
{
tok
->
done
=
E_TOKEN
;
if
(
!
isdigit
(
c
))
{
tok
->
done
=
E_TOKEN
;
tok_backup
(
tok
,
c
);
return
ERRORTOKEN
;
}
}
else
if
(
!
isdigit
(
c
))
{
tok_backup
(
tok
,
c
);
return
ERRORTOKEN
;
tok_backup
(
tok
,
e
);
*
p_start
=
tok
->
start
;
*
p_end
=
tok
->
cur
;
return
NUMBER
;
}
do
{
c
=
tok_nextc
(
tok
);
...
...
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