BUG: Trivial fix to #15447
 - [x] closes #15447
 - [ ] tests added / passed
 - [x] passes ``git diff upstream/master | flake8 --diff``
 - [ ] whatsnew entry

This is not really meant for merging because I don't understand that piece code and don't have time to understand it. But if you want to merge it anyway I can add a test and a whatsnew entry.