CLN GH22875 Replace bare excepts by explicit excepts in pandas/io/
State: closed

- [X] closes #22875
- [X] tests added / passed
- [X] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

This is a resubmit of a previous PR I submitted that was approved (#22916). I tried to close and reopen to get a rebuild on travis but I couldn't reopen it because I had deleted my old fork (after accidentally pushing to master).

Labels:
name: Error Reporting
description: Incorrect or improved errors from pandas

Comments:
Hello @JustinZhengBC! Thanks for updating the PR.

 - There are no PEP8 issues in the file [`pandas/io/clipboards.py`](https://github.com/JustinZhengBC/pandas/blob/e6610fa5b0856537ec43577f943e8a0c17d55bfa/pandas/io/clipboards.py) !

 - There are no PEP8 issues in the file [`pandas/io/formats/console.py`](https://github.com/JustinZhengBC/pandas/blob/e6610fa5b0856537ec43577f943e8a0c17d55bfa/pandas/io/formats/console.py) !

 - There are no PEP8 issues in the file [`pandas/io/formats/terminal.py`](https://github.com/JustinZhengBC/pandas/blob/e6610fa5b0856537ec43577f943e8a0c17d55bfa/pandas/io/formats/terminal.py) !

 - There are no PEP8 issues in the file [`pandas/io/packers.py`](https://github.com/JustinZhengBC/pandas/blob/e6610fa5b0856537ec43577f943e8a0c17d55bfa/pandas/io/packers.py) !

 - There are no PEP8 issues in the file [`pandas/io/parsers.py`](https://github.com/JustinZhengBC/pandas/blob/e6610fa5b0856537ec43577f943e8a0c17d55bfa/pandas/io/parsers.py) !

 - There are no PEP8 issues in the file [`pandas/io/pickle.py`](https://github.com/JustinZhengBC/pandas/blob/e6610fa5b0856537ec43577f943e8a0c17d55bfa/pandas/io/pickle.py) !

 - There are no PEP8 issues in the file [`pandas/io/sas/sas_xport.py`](https://github.com/JustinZhengBC/pandas/blob/e6610fa5b0856537ec43577f943e8a0c17d55bfa/pandas/io/sas/sas_xport.py) !

 - There are no PEP8 issues in the file [`pandas/io/sas/sasreader.py`](https://github.com/JustinZhengBC/pandas/blob/e6610fa5b0856537ec43577f943e8a0c17d55bfa/pandas/io/sas/sasreader.py) !

 - There are no PEP8 issues in the file [`pandas/io/sql.py`](https://github.com/JustinZhengBC/pandas/blob/e6610fa5b0856537ec43577f943e8a0c17d55bfa/pandas/io/sql.py) !

 - There are no PEP8 issues in the file [`pandas/io/stata.py`](https://github.com/JustinZhengBC/pandas/blob/e6610fa5b0856537ec43577f943e8a0c17d55bfa/pandas/io/stata.py) !



##### Comment last updated on October 09, 2018 at 18:52 Hours UTC
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23004?src=pr&el=h1) Report
> Merging [#23004](https://codecov.io/gh/pandas-dev/pandas/pull/23004?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/4976ee1c93bcc6327ca5e8714ad326c126f4151e?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `36.84%`.

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

```diff
@@            Coverage Diff             @@
##           master   #23004      +/-   ##
==========================================
+ Coverage   92.19%   92.19%   +<.01%     
==========================================
  Files         169      169              
  Lines       50831    50911      +80     
==========================================
+ Hits        46864    46939      +75     
- Misses       3967     3972       +5
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.61% <36.84%> (ø)` | :arrow_up: |
| #single | `42.3% <5.26%> (-0.05%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/23004?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/clipboards.py](https://codecov.io/gh/pandas-dev/pandas/pull/23004/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2NsaXBib2FyZHMucHk=) | `100% <ø> (ø)` | :arrow_up: |
| [pandas/io/formats/terminal.py](https://codecov.io/gh/pandas-dev/pandas/pull/23004/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvdGVybWluYWwucHk=) | `21.25% <0%> (ø)` | :arrow_up: |
| [pandas/io/sas/sas\_xport.py](https://codecov.io/gh/pandas-dev/pandas/pull/23004/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNfeHBvcnQucHk=) | `90.23% <0%> (ø)` | :arrow_up: |
| [pandas/io/sas/sasreader.py](https://codecov.io/gh/pandas-dev/pandas/pull/23004/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNyZWFkZXIucHk=) | `86.2% <0%> (ø)` | :arrow_up: |
| [pandas/io/packers.py](https://codecov.io/gh/pandas-dev/pandas/pull/23004/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3BhY2tlcnMucHk=) | `88.04% <50%> (ø)` | :arrow_up: |
| [pandas/io/parsers.py](https://codecov.io/gh/pandas-dev/pandas/pull/23004/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3BhcnNlcnMucHk=) | `95.6% <50%> (ø)` | :arrow_up: |
| [pandas/io/formats/console.py](https://codecov.io/gh/pandas-dev/pandas/pull/23004/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvY29uc29sZS5weQ==) | `75.75% <75%> (ø)` | :arrow_up: |
| [pandas/core/internals/concat.py](https://codecov.io/gh/pandas-dev/pandas/pull/23004/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2NvbmNhdC5weQ==) | `98% <0%> (-0.38%)` | :arrow_down: |
| [pandas/core/indexes/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/23004/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9wZXJpb2QucHk=) | `93.31% <0%> (-0.35%)` | :arrow_down: |
| ... and [15 more](https://codecov.io/gh/pandas-dev/pandas/pull/23004/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23004?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/23004?src=pr&el=footer). Last update [4976ee1...ee85901](https://codecov.io/gh/pandas-dev/pandas/pull/23004?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

@jreback the tests are green now.

Also, I have another PR with a similar problem (#22904). Is there a way to force travis to rebuild without committing new changes or should I just resubmit the PR?
> Also, I have another PR with a similar problem (#22904). Is there a way to force travis to rebuild without committing new changes or should I just resubmit the PR?

you can just push another commit, or generate a new hash
``git commit --all --amend -C HEAD``
Output of benchmark tests:
```
· Creating environments
· Discovering benchmarks
· Running 4 total benchmarks (2 commits * 1 environments * 2 benchmarks)
[  0.00%] · For pandas commit ee808033 <master> (round 1/2):
[  0.00%] ·· Building for conda-py3.6-Cython-matplotlib-numexpr-numpy-openpyxl-pytables-pytest-scipy-sqlalchemy-xlrd-xlsxwriter-xlwt..............................................
[  0.00%] ·· Benchmarking conda-py3.6-Cython-matplotlib-numexpr-numpy-openpyxl-pytables-pytest-scipy-sqlalchemy-xlrd-xlsxwriter-xlwt
[ 12.50%] ··· Running (io.pickle.Pickle.time_read_pickle--)..
[ 25.00%] · For pandas commit 6b54cf8b <BUG-22984> (round 1/2):
[ 25.00%] ·· Building for conda-py3.6-Cython-matplotlib-numexpr-numpy-openpyxl-pytables-pytest-scipy-sqlalchemy-xlrd-xlsxwriter-xlwt...
[ 25.00%] ·· Benchmarking conda-py3.6-Cython-matplotlib-numexpr-numpy-openpyxl-pytables-pytest-scipy-sqlalchemy-xlrd-xlsxwriter-xlwt
[ 37.50%] ··· Running (io.pickle.Pickle.time_read_pickle--)..
[ 50.00%] · For pandas commit 6b54cf8b <BUG-22984> (round 2/2):
[ 50.00%] ·· Benchmarking conda-py3.6-Cython-matplotlib-numexpr-numpy-openpyxl-pytables-pytest-scipy-sqlalchemy-xlrd-xlsxwriter-xlwt
[ 62.50%] ··· io.pickle.Pickle.time_read_pickle                         23.0±2ms
[ 75.00%] ··· io.pickle.Pickle.time_write_pickle                        20.9±1ms
[ 75.00%] · For pandas commit ee808033 <master> (round 2/2):
[ 75.00%] ·· Building for conda-py3.6-Cython-matplotlib-numexpr-numpy-openpyxl-pytables-pytest-scipy-sqlalchemy-xlrd-xlsxwriter-xlwt...
[ 75.00%] ·· Benchmarking conda-py3.6-Cython-matplotlib-numexpr-numpy-openpyxl-pytables-pytest-scipy-sqlalchemy-xlrd-xlsxwriter-xlwt
[ 87.50%] ··· io.pickle.Pickle.time_read_pickle                         21.9±1ms
[100.00%] ··· io.pickle.Pickle.time_write_pickle                        21.0±1ms

BENCHMARKS NOT SIGNIFICANTLY CHANGED.
```


Both the remaining except blocks are necessary, as removing them will result in test failures.


Upon further thought, I suppose it could be argued that the branch should remain in case someone modifies the load function later so that compat is used again. Should I put it back?
yeah let's just put it back, but you can add a TODO that should see if can be removed safely., breaking pickle is not great and this is not super well tested. 
lgtm. merge on green.
Thanks for the fixes @JustinZhengBC, good work.