Fixes for cross-Python compatibility