Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
575d766a
Commit
575d766a
authored
Jan 06, 1997
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for duplicate keyword arguments at compile time.
parent
aac36f2e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
12 deletions
+20
-12
Python/compile.c
Python/compile.c
+20
-12
No files found.
Python/compile.c
View file @
575d766a
...
...
@@ -282,6 +282,7 @@ com_error(c, exc, msg)
object
*
v
;
char
buffer
[
30
];
char
*
s
;
c
->
c_errors
++
;
if
(
c
->
c_lineno
<=
1
)
{
/* Unknown line number or single interactive command */
err_setstr
(
exc
,
msg
);
...
...
@@ -296,7 +297,6 @@ com_error(c, exc, msg)
strcat
(
s
,
buffer
);
err_setval
(
exc
,
v
);
DECREF
(
v
);
c
->
c_errors
++
;
}
...
...
@@ -913,23 +913,23 @@ com_slice(c, n, op)
}
}
static
int
com_argument
(
c
,
n
,
in
keywords
)
static
void
com_argument
(
c
,
n
,
p
keywords
)
struct
compiling
*
c
;
node
*
n
;
/* argument */
int
in
keywords
;
object
**
p
keywords
;
{
node
*
m
;
REQ
(
n
,
argument
);
/* [test '='] test; really [ keyword '='] keyword */
if
(
NCH
(
n
)
==
1
)
{
if
(
inkeywords
)
{
if
(
*
pkeywords
!=
NULL
)
{
com_error
(
c
,
SyntaxError
,
"non-keyword arg after keyword arg"
);
}
else
{
com_node
(
c
,
CHILD
(
n
,
0
));
}
return
0
;
return
;
}
m
=
n
;
do
{
...
...
@@ -940,15 +940,22 @@ com_argument(c, n, inkeywords)
}
else
{
object
*
v
=
newstringobject
(
STR
(
m
));
if
(
v
==
NULL
)
if
(
v
!=
NULL
&&
*
pkeywords
==
NULL
)
*
pkeywords
=
newdictobject
();
if
(
v
==
NULL
||
*
pkeywords
==
NULL
)
c
->
c_errors
++
;
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
));
DECREF
(
v
);
}
}
com_node
(
c
,
CHILD
(
n
,
2
));
return
1
;
}
static
void
...
...
@@ -960,18 +967,19 @@ com_call_function(c, n)
com_addoparg
(
c
,
CALL_FUNCTION
,
0
);
}
else
{
int
inkeywords
,
i
,
na
,
nk
;
object
*
keywords
=
NULL
;
int
i
,
na
,
nk
;
REQ
(
n
,
arglist
);
inkeywords
=
0
;
na
=
0
;
nk
=
0
;
for
(
i
=
0
;
i
<
NCH
(
n
);
i
+=
2
)
{
inkeywords
=
com_argument
(
c
,
CHILD
(
n
,
i
),
in
keywords
);
if
(
!
inkeywords
)
com_argument
(
c
,
CHILD
(
n
,
i
),
&
keywords
);
if
(
keywords
==
NULL
)
na
++
;
else
nk
++
;
}
XDECREF
(
keywords
);
if
(
na
>
255
||
nk
>
255
)
{
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