Skip to content

Commit 00aabe7

Browse files
committed
Fixes mbj4668#690: Stop uses expanding if import circular dependency exists
1 parent 045383e commit 00aabe7

File tree

5 files changed

+67
-1
lines changed

5 files changed

+67
-1
lines changed

pyang/statements.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,7 @@ def v_expand_1_uses(ctx, stmt):
14911491
if getattr(stmt, 'is_grammatically_valid', None) is False:
14921492
return
14931493

1494-
if stmt.i_grouping is None:
1494+
if not hasattr(stmt, 'i_grouping') or stmt.i_grouping is None:
14951495
return
14961496

14971497
# possibly expand any uses within the grouping

test/test_issues/test_i690/Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
test: test1
2+
3+
test1:
4+
-$(PYANG) test.yang --print-error-code 2>&1 | diff main.expect -
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test2.yang:9: error: CIRCULAR_DEPENDENCY

test/test_issues/test_i690/test.yang

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module test {
2+
3+
yang-version "1";
4+
5+
namespace "http://test";
6+
7+
prefix test;
8+
9+
import test2 {
10+
prefix test2;
11+
}
12+
13+
14+
organization "x";
15+
contact "x";
16+
description "x";
17+
18+
revision 2017-04-21 {
19+
description "1st revision.";
20+
}
21+
22+
grouping testgrouping1 {
23+
leaf test {
24+
type string;
25+
}
26+
}
27+
grouping testgrouping {
28+
uses testgrouping1;
29+
}
30+
31+
uses test2:testgrouping;
32+
}

test/test_issues/test_i690/test2.yang

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module test2 {
2+
3+
yang-version "1";
4+
5+
namespace "http://test2";
6+
7+
prefix test2;
8+
9+
import test {
10+
prefix test;
11+
}
12+
13+
organization "x";
14+
contact "x";
15+
description "x";
16+
17+
revision 2017-04-21 {
18+
description "1st revision.";
19+
}
20+
21+
container one {
22+
leaf two {
23+
type string;
24+
}
25+
}
26+
grouping testgrouping {
27+
uses test:testgrouping;
28+
}
29+
}

0 commit comments

Comments
 (0)