fix #6653

Backport of 4c3dd9f3ccd3740a6973724a66fb75cd2665c4dc to fix #6653 the 0.2 release branch.
cc: @stevengj