Thanks thibaultj for the report, jenh for the patch, and charettes for the tests. Backport of aa830009 from master