Skip to content

Commit

Permalink
adapt the Request.source property to python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco committed Jan 26, 2019
1 parent 7f79c6a commit a51b9c0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion liberapay/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ def _Querystring_derive(self, **kw):
raise Warning('pando.http.request.Request.source already exists')
def _source(self):
def f():
addr = ip_address(self.environ[b'REMOTE_ADDR'].decode('ascii'))
addr = self.environ.get('REMOTE_ADDR') or self.environ[b'REMOTE_ADDR']
addr = ip_address(addr.decode('ascii') if type(addr) is bytes else addr)
trusted_proxies = getattr(self.website, 'trusted_proxies', None)
forwarded_for = self.headers.get(b'X-Forwarded-For')
self.__dict__['bypasses_proxy'] = bool(trusted_proxies)
Expand Down

0 comments on commit a51b9c0

Please sign in to comment.