From 13fd5ed51acece634b3faface1e758e7cda496d7 Mon Sep 17 00:00:00 2001 From: Chad Birch Date: Mon, 23 Dec 2013 14:41:34 -0700 Subject: [PATCH] UrlParser: tolerate port attribute being unset --- r2/r2/lib/utils/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/r2/r2/lib/utils/utils.py b/r2/r2/lib/utils/utils.py index 25cfd0921..76beb9bdd 100644 --- a/r2/r2/lib/utils/utils.py +++ b/r2/r2/lib/utils/utils.py @@ -450,7 +450,7 @@ class UrlParser(object): q = query_string(q).lstrip('?') # make sure the port is not doubly specified - if self.port and ":" in self.hostname: + if getattr(self, 'port', None) and ":" in self.hostname: self.hostname = self.hostname.split(':')[0] # if there is a netloc, there had better be a scheme @@ -552,7 +552,7 @@ class UrlParser(object): # update the domain (preserving the port) self.hostname = subreddit.domain - self.port = self.port or port + self.port = getattr(self, 'port', None) or port # and remove any cnameframe GET parameters if self.query_dict.has_key(self.cname_get):