From 52feff266ebc39569f0839104c25fb9386e89707 Mon Sep 17 00:00:00 2001 From: Raphael Deem Date: Wed, 13 Dec 2017 23:14:54 -0800 Subject: [PATCH] fix edge case with methods as None --- sanic/router.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sanic/router.py b/sanic/router.py index f97cdbde..080f4c5d 100644 --- a/sanic/router.py +++ b/sanic/router.py @@ -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):