backport. closes #460, #552, which were also fixed going forward by https://github.com/Pylons/pyramid/commit/95d5b72927484fa3882c5c47bf79d591a5af50a5
Merge pull request #1511 from stevepiercy/1.3-branch

backport. closes #460, #552, which were also fixed going forward by http...