[xy] fail assertion only if existing prefix is being changed (closes #139999)

authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
changeset851ea9542d0c
branchdefault
phasedraft
hiddenyes
parent revision#153169d841bd Added tag for version 0.37.0 on changeset 25d0bff4eb9d
child revision<not specified>
files modified by this revision
xy.py
# HG changeset patch
# User Nicolas Chauvat <nicolas.chauvat@logilab.fr>
# Date 1366961649 -7200
# Fri Apr 26 09:34:09 2013 +0200
# Node ID 851ea9542d0c1204ce792cfc8a154d8e521a21e5
# Parent 153169d841bdeb1e091e58c909c938a93aa5a0e6
[xy] fail assertion only if existing prefix is being changed (closes #139999)

diff --git a/xy.py b/xy.py
@@ -35,11 +35,13 @@
1          if ':' in prefix:
2              warn('[yams 0.30] register_prefix arguments has been switched to '
3                   '(prefix, xmlns)', DeprecationWarning, stacklevel=2)
4              prefix, xmlns = xmlns, prefix
5          if not overwrite:
6 -            assert not prefix in self.prefixes, 'prefix already defined'
7 +            if prefix in self.prefixes and self.prefixes.get(prefix) != xmlns:
8 +                print prefix, xmlns, self.prefixes[prefix]
9 +                raise Exception('prefix already defined with different value')
10          self.prefixes[prefix] = xmlns
11 
12      def _norm_yams_key(self, yamssnippet):
13          parts = yamssnippet.split(' ')
14          if len(parts) == 1: