utils/web.py: Fix compatibility with Python 3.