Mercurial > hgrepos > Python > libs > ConfigMix
comparison configmix/yaml.py @ 686:80d203ed3556
FIX: The YAML loader had wrong format strings in its exception handlers.
This is a code-path that is executed extremely rarely.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sat, 10 Jun 2023 21:58:16 +0200 |
| parents | f454889e41fa |
| children |
comparison
equal
deleted
inserted
replaced
| 685:2e7920b0b4d9 | 686:80d203ed3556 |
|---|---|
| 77 try: | 77 try: |
| 78 hash(key) | 78 hash(key) |
| 79 except TypeError as err: | 79 except TypeError as err: |
| 80 raise yaml.constructor.ConstructorError( | 80 raise yaml.constructor.ConstructorError( |
| 81 'while constructing a mapping', node.start_mark, | 81 'while constructing a mapping', node.start_mark, |
| 82 'found unacceptable key (%s)' % (err, | 82 'found unacceptable key (%s)' % (err, ), |
| 83 key_node.start_mark) | 83 key_node.start_mark) |
| 84 ) | |
| 85 value = self.construct_object(value_node, deep=deep) | 84 value = self.construct_object(value_node, deep=deep) |
| 86 if not self.__allow_duplicate_keys and key in mapping: | 85 if not self.__allow_duplicate_keys and key in mapping: |
| 87 raise yaml.constructor.ConstructorError( | 86 raise yaml.constructor.ConstructorError( |
| 88 'while constructing a mapping', node.start_mark, | 87 'while constructing a mapping', node.start_mark, |
| 89 'found duplicate key %r (%s)' % (key, | 88 'found duplicate key %r' % (key, ), |
| 90 key_node.start_mark) | 89 key_node.start_mark) |
| 91 ) | |
| 92 mapping[key] = value | 90 mapping[key] = value |
| 93 return mapping | 91 return mapping |
| 94 | 92 |
| 95 | 93 |
| 96 ConfigLoader.add_constructor( | 94 ConfigLoader.add_constructor( |
| 142 raise yaml.constructor.ConstructorError( | 140 raise yaml.constructor.ConstructorError( |
| 143 None, | 141 None, |
| 144 None, | 142 None, |
| 145 'expected a mapping node, but found %s' % node.id, | 143 'expected a mapping node, but found %s' % node.id, |
| 146 node.start_mark) | 144 node.start_mark) |
| 147 | |
| 148 mapping = DictImpl() | 145 mapping = DictImpl() |
| 149 for key_node, value_node in node.value: | 146 for key_node, value_node in node.value: |
| 150 key = self.construct_object(key_node, deep=deep) | 147 key = self.construct_object(key_node, deep=deep) |
| 151 try: | 148 try: |
| 152 hash(key) | 149 hash(key) |
| 153 except TypeError as err: | 150 except TypeError as err: |
| 154 raise yaml.constructor.ConstructorError( | 151 raise yaml.constructor.ConstructorError( |
| 155 'while constructing a mapping', node.start_mark, | 152 'while constructing a mapping', node.start_mark, |
| 156 'found unacceptable key (%s)' % (err, | 153 'found unacceptable key (%s)' % (err, ), |
| 157 key_node.start_mark) | 154 key_node.start_mark) |
| 158 ) | |
| 159 value = self.construct_object(value_node, deep=deep) | 155 value = self.construct_object(value_node, deep=deep) |
| 160 if not self.__allow_duplicate_keys and key in mapping: | 156 if not self.__allow_duplicate_keys and key in mapping: |
| 161 raise yaml.constructor.ConstructorError( | 157 raise yaml.constructor.ConstructorError( |
| 162 'while constructing a mapping', node.start_mark, | 158 'while constructing a mapping', node.start_mark, |
| 163 'found duplicate key %r (%s)' % (key, | 159 'found duplicate key %r' % (key, ), |
| 164 key_node.start_mark) | 160 key_node.start_mark) |
| 165 ) | |
| 166 mapping[key] = value | 161 mapping[key] = value |
| 167 return mapping | 162 return mapping |
| 168 | 163 |
| 169 | 164 |
| 170 ConfigSafeLoader.add_constructor( | 165 ConfigSafeLoader.add_constructor( |
