fix edge case with methods as None

This commit is contained in:
Raphael Deem 2017-12-13 23:14:54 -08:00
parent 2c3f50e34a
commit 52feff266e

View File

@ -3,7 +3,7 @@ from collections import defaultdict, namedtuple
from collections.abc import Iterable
from functools import lru_cache
from sanic.exceptions import NotFound, InvalidUsage, MethodNotSupported
from sanic.exceptions import NotFound, MethodNotSupported
from sanic.views import CompositionView
Route = namedtuple(
@ -359,7 +359,8 @@ class Router:
:return: frozenset of supported methods
"""
route = self.routes_all.get(url)
return getattr(route, 'methods', frozenset())
# if methods are None then this logic will prevent an error
return getattr(route, 'methods', None) or frozenset()
@lru_cache(maxsize=ROUTER_CACHE_SIZE)
def _get(self, url, method, host):