diff --git a/src/rougail/objspace.py b/src/rougail/objspace.py index 127bc2c5..7c97b0a0 100644 --- a/src/rougail/objspace.py +++ b/src/rougail/objspace.py @@ -356,7 +356,7 @@ class RougailObjSpace: # it's not a family tag = FORCE_TAG.get(child.tag, child.tag) children = getattr(space, tag, {}) - if name in children: + if name in children and isinstance(children[name], getattr(self, child.tag)): return children[name] return None diff --git a/src/rougail/path.py b/src/rougail/path.py index ff1a2b78..b2b45eb8 100644 --- a/src/rougail/path.py +++ b/src/rougail/path.py @@ -66,6 +66,9 @@ class Path: if full_name in self.families and \ self.families[full_name]['variableobj'] != variableobj: # pragma: no cover raise DictConsistencyError(_(f'Duplicate family name "{name}"'), 37, variableobj.xmlfiles) + if full_name in self.variables: + msg = _(f'A variable and a family has the same path "{full_name}"') + raise DictConsistencyError(msg, 56, variableobj.xmlfiles) self.families[full_name] = dict(name=name, namespace=namespace, variableobj=variableobj, @@ -150,6 +153,9 @@ class Path: else: full_path = name variableobj.path = full_path + if full_path in self.families: + msg = _(f'A family and a variable has the same path "{full_path}"') + raise DictConsistencyError(msg, 57, variableobj.xmlfiles) self.variables[full_path] = dict(name=name, family=family, leader=None, diff --git a/tests/dictionaries/80family_variable_not_same_name/00-base.xml b/tests/dictionaries/80family_variable_not_same_name/00-base.xml new file mode 100644 index 00000000..b95506cc --- /dev/null +++ b/tests/dictionaries/80family_variable_not_same_name/00-base.xml @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/tests/dictionaries/80family_variable_not_same_name/__init__.py b/tests/dictionaries/80family_variable_not_same_name/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/dictionaries/80family_variable_not_same_name/errno_57 b/tests/dictionaries/80family_variable_not_same_name/errno_57 new file mode 100644 index 00000000..e69de29b diff --git a/tests/dictionaries/80variable_family_not_same_name/00-base.xml b/tests/dictionaries/80variable_family_not_same_name/00-base.xml new file mode 100644 index 00000000..3ca4e3da --- /dev/null +++ b/tests/dictionaries/80variable_family_not_same_name/00-base.xml @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/tests/dictionaries/80variable_family_not_same_name/__init__.py b/tests/dictionaries/80variable_family_not_same_name/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/dictionaries/80variable_family_not_same_name/errno_56 b/tests/dictionaries/80variable_family_not_same_name/errno_56 new file mode 100644 index 00000000..e69de29b