Backported r33358 from the 1.4 branch, it fixes bug #10003