[compat] Simplify and use latest cpython 3 code