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
1bb62309
Kaydet (Commit)
1bb62309
authored
May 03, 2006
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Bug #1385040: don't allow "def foo(a=1, b): pass" in the compiler package.
üst
23d9d454
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
+11
-7
transformer.py
Lib/compiler/transformer.py
+5
-7
test_compiler.py
Lib/test/test_compiler.py
+3
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/compiler/transformer.py
Dosyayı görüntüle @
1bb62309
...
@@ -841,17 +841,15 @@ class Transformer:
...
@@ -841,17 +841,15 @@ class Transformer:
names
.
append
(
self
.
com_fpdef
(
node
))
names
.
append
(
self
.
com_fpdef
(
node
))
i
=
i
+
1
i
=
i
+
1
if
i
>=
len
(
nodelist
):
if
i
<
len
(
nodelist
)
and
nodelist
[
i
][
0
]
==
token
.
EQUAL
:
break
if
nodelist
[
i
][
0
]
==
token
.
EQUAL
:
defaults
.
append
(
self
.
com_node
(
nodelist
[
i
+
1
]))
defaults
.
append
(
self
.
com_node
(
nodelist
[
i
+
1
]))
i
=
i
+
2
i
=
i
+
2
elif
len
(
defaults
):
elif
len
(
defaults
):
#
XXX This should be a syntax error.
#
we have already seen an argument with default, but here
#
Treat "(a=1, b)" as "(a=1, b=None)"
#
came one without
defaults
.
append
(
Const
(
None
))
raise
SyntaxError
,
"non-default argument follows default argument"
# skip the comma
i
=
i
+
1
i
=
i
+
1
return
names
,
defaults
,
flags
return
names
,
defaults
,
flags
...
...
Lib/test/test_compiler.py
Dosyayı görüntüle @
1bb62309
...
@@ -56,6 +56,9 @@ class CompilerTest(unittest.TestCase):
...
@@ -56,6 +56,9 @@ class CompilerTest(unittest.TestCase):
def
testYieldExpr
(
self
):
def
testYieldExpr
(
self
):
compiler
.
compile
(
"def g(): yield
\n\n
"
,
"<string>"
,
"exec"
)
compiler
.
compile
(
"def g(): yield
\n\n
"
,
"<string>"
,
"exec"
)
def
testDefaultArgs
(
self
):
self
.
assertRaises
(
SyntaxError
,
compiler
.
parse
,
"def foo(a=1, b): pass"
)
def
testLineNo
(
self
):
def
testLineNo
(
self
):
# Test that all nodes except Module have a correct lineno attribute.
# Test that all nodes except Module have a correct lineno attribute.
filename
=
__file__
filename
=
__file__
...
...
Misc/NEWS
Dosyayı görüntüle @
1bb62309
...
@@ -91,6 +91,9 @@ Extension Modules
...
@@ -91,6 +91,9 @@ Extension Modules
Library
Library
-------
-------
- Bug #1385040: don'
t
allow
"def foo(a=1, b): pass"
in
the
compiler
package
.
-
Patch
#
1472854
:
make
the
rlcompleter
.
Completer
class
usable
on
non
-
-
Patch
#
1472854
:
make
the
rlcompleter
.
Completer
class
usable
on
non
-
UNIX
platforms
.
UNIX
platforms
.
...
...
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