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
71137083
Commit
71137083
authored
Jan 07, 2001
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix problems with validation of import statement parse trees.
This closes SF bug #127271.
parent
1109db44
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
5 deletions
+24
-5
Modules/parsermodule.c
Modules/parsermodule.c
+24
-5
No files found.
Modules/parsermodule.c
View file @
71137083
...
...
@@ -1558,6 +1558,25 @@ validate_import_as_name(node *tree)
}
/* dotted_name: NAME ("." NAME)*
*/
static
int
validate_dotted_name
(
node
*
tree
)
{
int
nch
=
NCH
(
tree
);
int
res
=
(
validate_ntype
(
tree
,
dotted_name
)
&&
is_odd
(
nch
)
&&
validate_name
(
CHILD
(
tree
,
0
),
NULL
));
int
i
;
for
(
i
=
1
;
res
&&
(
i
<
nch
);
i
+=
2
)
{
res
=
(
validate_dot
(
CHILD
(
tree
,
i
))
&&
validate_name
(
CHILD
(
tree
,
i
+
1
),
NULL
));
}
return
res
;
}
/* dotted_as_name: dotted_name [NAME NAME]
*/
static
int
...
...
@@ -1568,9 +1587,9 @@ validate_dotted_as_name(node *tree)
if
(
res
)
{
if
(
nch
==
1
)
res
=
validate_
ntype
(
CHILD
(
tree
,
0
),
dotted_name
);
res
=
validate_
dotted_name
(
CHILD
(
tree
,
0
)
);
else
if
(
nch
==
3
)
res
=
(
validate_
ntype
(
CHILD
(
tree
,
0
),
dotted_name
)
res
=
(
validate_
dotted_name
(
CHILD
(
tree
,
0
)
)
&&
validate_name
(
CHILD
(
tree
,
1
),
"as"
)
&&
validate_name
(
CHILD
(
tree
,
2
),
NULL
));
else
{
...
...
@@ -1601,12 +1620,12 @@ validate_import_stmt(node *tree)
res
=
validate_dotted_as_name
(
CHILD
(
tree
,
1
));
for
(
j
=
2
;
res
&&
(
j
<
nch
);
j
+=
2
)
res
=
(
validate_comma
(
CHILD
(
tree
,
j
))
&&
validate_
ntype
(
CHILD
(
tree
,
j
+
1
),
dotted_name
));
&&
validate_
dotted_as_name
(
CHILD
(
tree
,
j
+
1
)
));
}
else
if
(
res
&&
(
res
=
validate_name
(
CHILD
(
tree
,
0
),
"from"
)))
{
res
=
((
nch
>=
4
)
&&
is_even
(
nch
)
&&
validate_
name
(
CHILD
(
tree
,
2
),
"import"
)
&&
validate_
dotted_as_name
(
CHILD
(
tree
,
1
)
));
&&
validate_
dotted_name
(
CHILD
(
tree
,
1
)
)
&&
validate_
name
(
CHILD
(
tree
,
2
),
"import"
));
if
(
nch
==
4
)
{
if
(
TYPE
(
CHILD
(
tree
,
3
))
==
import_as_name
)
res
=
validate_import_as_name
(
CHILD
(
tree
,
3
));
...
...
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