This bug was already fixed in the v0.8 branch but git skips the patch when merging v0.8 into master. Reapply it manually. Fixes #3961.