Fix 1040

Fixes issue 1040.

https://github.com/Pylons/pyramid/issues/1040