RegexUrlResolver's _get_reverse_dict appends objects of unknown type to the reverse dict
|Reported by:||fas||Owned by:||fas|
|Severity:||Keywords:||url, urlresolver, regexurlpattern, regexurlresolver|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
if isinstance(pattern, RegexURLResolver): # ... else: bits = normalize(p_pattern) self._reverse_dict.appendlist(pattern.callback, (bits, p_pattern)) self._reverse_dict.appendlist(pattern.name, (bits, p_pattern))
In the else branch it is implicitly assumed that pattern is of type RegexURLPattern (it uses its properties). This does not have to be the case. For example, one could create a different kind of RegexURLResolver which does not inherit RegexURLResolver. This resolver would be handled as a RegexURLPattern instance and added to the reverse dict.
Patch is a short one: replace "else" with "elif isinstance(pattern, RegexURLPattern):".