Safely raise errors when object contains unicode
State: closed

This safely turns nd.array objects that contain unicode into a
representation that can be printed

Checklist for other PRs (remove this part if you are doing a PR for the pandas documentation sprint):

- [x] closes #20503
- [ ] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry


Labels:
name: Testing
description: pandas testing functions or related to the test suite
name: Unicode
description: Unicode strings

Comments:
This needs tests - can you add some in `pandas/tests/util/test_testing.py`?
Hello @janrito! Thanks for updating the PR.





Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on April 09, 2018 at 17:34 Hours UTC
Thanks for the review @jreback! I've changed the message, separated the tests and added comments referencing the gh issue
Tests are failing on python3, not sure how to deal with the printing issue 

It seems like error messages are converted to native str type (binary in py2 and unicode in py3) so either way we encode this will add u or b prefixes to the objects 
Ok, I'm not sure if this is the most elegant way of dealing with it, but if we encode only on python2 when the objects are base_strings, it doesn't print the text type prefixes in either python version
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20593?src=pr&el=h1) Report
> Merging [#20593](https://codecov.io/gh/pandas-dev/pandas/pull/20593?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/73cb32e71469cf1615907544728bb9a751089de4?src=pr&el=desc) will **increase** coverage by `0.01%`.
> The diff coverage is `50%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/20593/graphs/tree.svg?token=eZ4WkYLtcO&height=150&src=pr&width=650)](https://codecov.io/gh/pandas-dev/pandas/pull/20593?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #20593      +/-   ##
==========================================
+ Coverage   91.82%   91.83%   +0.01%     
==========================================
  Files         153      153              
  Lines       49256    49269      +13     
==========================================
+ Hits        45229    45247      +18     
+ Misses       4027     4022       -5
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.22% <50%> (+0.01%)` | :arrow_up: |
| #single | `41.9% <0%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/20593?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/20593/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `84.38% <50%> (-0.35%)` | :arrow_down: |
| [pandas/plotting/\_core.py](https://codecov.io/gh/pandas-dev/pandas/pull/20593/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb3JlLnB5) | `82.39% <0%> (-0.12%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/20593/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.15% <0%> (ø)` | :arrow_up: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/20593/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (ø)` | :arrow_up: |
| [pandas/util/\_test\_decorators.py](https://codecov.io/gh/pandas-dev/pandas/pull/20593/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvX3Rlc3RfZGVjb3JhdG9ycy5weQ==) | `92% <0%> (+0.1%)` | :arrow_up: |
| [pandas/plotting/\_converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/20593/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb252ZXJ0ZXIucHk=) | `66.81% <0%> (+1.73%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20593?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20593?src=pr&el=footer). Last update [73cb32e...1f7e231](https://codecov.io/gh/pandas-dev/pandas/pull/20593?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

thanks @janrito nice patch!