backport master fix from Pylons/pyramid#1032 to 1.4-branch