Fix regression from #581

@simonster could you comment on what exactly d3a69be9970035befda4547c06ea48804f138129 was fixing? I'm having a hard time finding any sort of release note or bug report relating to this fix and I can't really trigger an error after removing it.