Add support and fix tests for Python 3.9. Please see details in the individual patches.
/cc @jerome, @gabriel