Add backward compatibility for Python 2.