Restore support for Python < 2.7.9

See Python issue 21591 for details: http://bugs.python.org/issue21591

The combination of exec and a closure caused a problem on Python 2 older than 2.7.9. That was only released in December 2014, so we probably can't require it yet.