Backport #1506 from 1.2.5