Fix search inconsistency between Python versions

Closes #2012