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
635abd24
Kaydet (Commit)
635abd24
authored
Ock 06, 1997
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Check for duplicate keyword arguments at compile time.
üst
8f49e12a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
12 deletions
+20
-12
compile.c
Python/compile.c
+20
-12
No files found.
Python/compile.c
Dosyayı görüntüle @
635abd24
...
@@ -282,6 +282,7 @@ com_error(c, exc, msg)
...
@@ -282,6 +282,7 @@ com_error(c, exc, msg)
object
*
v
;
object
*
v
;
char
buffer
[
30
];
char
buffer
[
30
];
char
*
s
;
char
*
s
;
c
->
c_errors
++
;
if
(
c
->
c_lineno
<=
1
)
{
if
(
c
->
c_lineno
<=
1
)
{
/* Unknown line number or single interactive command */
/* Unknown line number or single interactive command */
err_setstr
(
exc
,
msg
);
err_setstr
(
exc
,
msg
);
...
@@ -296,7 +297,6 @@ com_error(c, exc, msg)
...
@@ -296,7 +297,6 @@ com_error(c, exc, msg)
strcat
(
s
,
buffer
);
strcat
(
s
,
buffer
);
err_setval
(
exc
,
v
);
err_setval
(
exc
,
v
);
DECREF
(
v
);
DECREF
(
v
);
c
->
c_errors
++
;
}
}
...
@@ -913,23 +913,23 @@ com_slice(c, n, op)
...
@@ -913,23 +913,23 @@ com_slice(c, n, op)
}
}
}
}
static
int
static
void
com_argument
(
c
,
n
,
in
keywords
)
com_argument
(
c
,
n
,
p
keywords
)
struct
compiling
*
c
;
struct
compiling
*
c
;
node
*
n
;
/* argument */
node
*
n
;
/* argument */
int
in
keywords
;
object
**
p
keywords
;
{
{
node
*
m
;
node
*
m
;
REQ
(
n
,
argument
);
/* [test '='] test; really [ keyword '='] keyword */
REQ
(
n
,
argument
);
/* [test '='] test; really [ keyword '='] keyword */
if
(
NCH
(
n
)
==
1
)
{
if
(
NCH
(
n
)
==
1
)
{
if
(
inkeywords
)
{
if
(
*
pkeywords
!=
NULL
)
{
com_error
(
c
,
SyntaxError
,
com_error
(
c
,
SyntaxError
,
"non-keyword arg after keyword arg"
);
"non-keyword arg after keyword arg"
);
}
}
else
{
else
{
com_node
(
c
,
CHILD
(
n
,
0
));
com_node
(
c
,
CHILD
(
n
,
0
));
}
}
return
0
;
return
;
}
}
m
=
n
;
m
=
n
;
do
{
do
{
...
@@ -940,15 +940,22 @@ com_argument(c, n, inkeywords)
...
@@ -940,15 +940,22 @@ com_argument(c, n, inkeywords)
}
}
else
{
else
{
object
*
v
=
newstringobject
(
STR
(
m
));
object
*
v
=
newstringobject
(
STR
(
m
));
if
(
v
==
NULL
)
if
(
v
!=
NULL
&&
*
pkeywords
==
NULL
)
*
pkeywords
=
newdictobject
();
if
(
v
==
NULL
||
*
pkeywords
==
NULL
)
c
->
c_errors
++
;
c
->
c_errors
++
;
else
{
else
{
if
(
dict2lookup
(
*
pkeywords
,
v
)
!=
NULL
)
com_error
(
c
,
SyntaxError
,
"duplicate keyword argument"
);
else
if
(
dict2insert
(
*
pkeywords
,
v
,
v
)
!=
0
)
c
->
c_errors
++
;
com_addoparg
(
c
,
LOAD_CONST
,
com_addconst
(
c
,
v
));
com_addoparg
(
c
,
LOAD_CONST
,
com_addconst
(
c
,
v
));
DECREF
(
v
);
DECREF
(
v
);
}
}
}
}
com_node
(
c
,
CHILD
(
n
,
2
));
com_node
(
c
,
CHILD
(
n
,
2
));
return
1
;
}
}
static
void
static
void
...
@@ -960,18 +967,19 @@ com_call_function(c, n)
...
@@ -960,18 +967,19 @@ com_call_function(c, n)
com_addoparg
(
c
,
CALL_FUNCTION
,
0
);
com_addoparg
(
c
,
CALL_FUNCTION
,
0
);
}
}
else
{
else
{
int
inkeywords
,
i
,
na
,
nk
;
object
*
keywords
=
NULL
;
int
i
,
na
,
nk
;
REQ
(
n
,
arglist
);
REQ
(
n
,
arglist
);
inkeywords
=
0
;
na
=
0
;
na
=
0
;
nk
=
0
;
nk
=
0
;
for
(
i
=
0
;
i
<
NCH
(
n
);
i
+=
2
)
{
for
(
i
=
0
;
i
<
NCH
(
n
);
i
+=
2
)
{
inkeywords
=
com_argument
(
c
,
CHILD
(
n
,
i
),
in
keywords
);
com_argument
(
c
,
CHILD
(
n
,
i
),
&
keywords
);
if
(
!
inkeywords
)
if
(
keywords
==
NULL
)
na
++
;
na
++
;
else
else
nk
++
;
nk
++
;
}
}
XDECREF
(
keywords
);
if
(
na
>
255
||
nk
>
255
)
{
if
(
na
>
255
||
nk
>
255
)
{
com_error
(
c
,
SyntaxError
,
"more than 255 arguments"
);
com_error
(
c
,
SyntaxError
,
"more than 255 arguments"
);
}
}
...
...
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