backport to 1.6 for #313