Python 3 compatibility changes (mostly in C compilation)