Fix scoping issue with Python 2.7