Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to python 3 #1399

Merged
merged 2 commits into from
Jan 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
python := "$(shell { command -v python2.7 || command -v python; } 2>/dev/null)"
python := "$(shell { command -v python3.6 || command -v python; } 2>/dev/null)"
install_where := $(shell $(python) -c "import sys; print('' if hasattr(sys, 'real_prefix') else '--user')")

# Set the relative path to installed binaries under the project virtualenv.
Expand Down Expand Up @@ -27,7 +27,7 @@ env: requirements*.txt

rehash-requirements:
for f in requirements*.txt; do \
sed -r -e '/^ +--hash/d' -e 's/\\$$//' $$f | xargs ./env/bin/hashin -r $$f -p 2.7 -p 3.6; \
sed -r -e '/^ +--hash/d' -e 's/\\$$//' $$f | xargs ./env/bin/hashin -r $$f -p 3.4 -p 3.6; \
done

clean:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ The python code inside simplates is only for request-specific logic, common back

Firstly, make sure you have the following dependencies installed:

- python ≥ 2.7.12 (the code is compatible with python 3, but production still runs on python 2 for now)
- python ≥ 3.6
- including the C headers of python and libffi, which are packaged separately in many Linux distributions
- postgresql 9.6 (see [the official download & install docs](https://www.postgresql.org/download/))
- make
Expand Down Expand Up @@ -178,7 +178,7 @@ All new dependencies need to be audited to check that they don't contain malicio
We use [pip's Hash-Checking Mode](https://pip.pypa.io/en/stable/reference/pip_install/#hash-checking-mode) to protect ourselves from dependency tampering. Thus when adding or upgrading a dependency the new hashes need to computed and put in the requirements file. For that you can use [hashin](https://github.com/peterbe/hashin):

pip install hashin
hashin package==x.y -r requirements_base.txt -p 2.7 -p 3.4 -p 3.6
hashin package==x.y -r requirements_base.txt -p 3.4 -p 3.6
# note: we have several requirements files, use the right one

If for some reason you need to rehash all requirements, run `make rehash-requirements`.
Expand Down
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