Issue #1374: Ported 101d8e9 into the 3.x branch