fix some Python compatibility issues