Correctly handle error when repr() fails due to non-string returned