Thanks Donald Stufft for the suggestion and Susan Tan and Brian Fabian Crain for the patch. Backport of ef8a9bc7 from master.