scons: fix build on Python pre-2.7

Fixes #31407.