Reapply #2052 for 3.9