Fixing a quirk in python folding

This fix doesn't seem to negatively impact performance, which is good, but I
should keep an eye on it.