Be more selecting about retcode, check for string or dict.  Thanks to @mzdaniel.  Fixes #16610 and includes a test.