Based on policy, either raise defect or call register_defect. handle_defect(obj, defect) defect should be a Defect subclass, but in any case must be an Exception subclass. obj is the object on which the defect should be registered if it is not raised. If the r
(self, obj, defect)
| 184 | verify_generated_headers = True |
| 185 | |
| 186 | def handle_defect(self, obj, defect): |
| 187 | """Based on policy, either raise defect or call register_defect. |
| 188 | |
| 189 | handle_defect(obj, defect) |
| 190 | |
| 191 | defect should be a Defect subclass, but in any case must be an |
| 192 | Exception subclass. obj is the object on which the defect should be |
| 193 | registered if it is not raised. If the raise_on_defect is True, the |
| 194 | defect is raised as an error, otherwise the object and the defect are |
| 195 | passed to register_defect. |
| 196 | |
| 197 | This method is intended to be called by parsers that discover defects. |
| 198 | The email package parsers always call it with Defect instances. |
| 199 | |
| 200 | """ |
| 201 | if self.raise_on_defect: |
| 202 | raise defect |
| 203 | self.register_defect(obj, defect) |
| 204 | |
| 205 | def register_defect(self, obj, defect): |
| 206 | """Record 'defect' on 'obj'. |