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

I removed the except block in pandas/io/pickle.py:172:13 because the only difference between the try block and the except block was one parameter in the call to pc.load, and the parameter that was changing didn't look like it was being used by pc.load.

Original block:
```
try:
    return read_wrapper(
        lambda f: pc.load(f, encoding=encoding, compat=False))
# compat pickle
except:
    return read_wrapper(
        lambda f: pc.load(f, encoding=encoding, compat=True))
```

The function it was calling (in pandas/compat/pickle_compat.py):
```
def load(fh, encoding=None, compat=False, is_verbose=False):
    """load a pickle, with a provided encoding

    if compat is True:
       fake the old class hierarchy
       if it works, then return the new type objects

    Parameters
    ----------
    fh: a filelike object
    encoding: an optional encoding
    compat: provide Series compatibility mode, boolean, default False
    is_verbose: show exception output
    """

    try:
        fh.seek(0)
        if encoding is not None:
            up = Unpickler(fh, encoding=encoding)
        else:
            up = Unpickler(fh)
        up.is_verbose = is_verbose

        return up.load()
    except:
        raise
```

Labels:
name: Error Reporting
description: Incorrect or improved errors from pandas
name: CI
description: Continuous Integration
name: Code Style
description: Code style, linting, code_checks

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

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

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

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

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

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

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

 - There are no PEP8 issues in the file [`pandas/io/sas/sas_xport.py`](https://github.com/JustinZhengBC/pandas/blob/b4f15c70349a4e470d0280bc5e1a0338b0b2fb30/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/b4f15c70349a4e470d0280bc5e1a0338b0b2fb30/pandas/io/sas/sasreader.py) !

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

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


# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22916?src=pr&el=h1) Report
> Merging [#22916](https://codecov.io/gh/pandas-dev/pandas/pull/22916?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/2f1b842119bc4d5242b587b62bde71d8f7ef19f8?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `31.57%`.

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

```diff
@@           Coverage Diff           @@
##           master   #22916   +/-   ##
=======================================
  Coverage   92.18%   92.18%           
=======================================
  Files         169      169           
  Lines       50830    50830           
=======================================
  Hits        46860    46860           
  Misses       3970     3970
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.6% <31.57%> (ø)` | :arrow_up: |
| #single | `42.37% <5.26%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/22916?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/clipboards.py](https://codecov.io/gh/pandas-dev/pandas/pull/22916/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2NsaXBib2FyZHMucHk=) | `100% <ø> (ø)` | :arrow_up: |
| [pandas/io/formats/terminal.py](https://codecov.io/gh/pandas-dev/pandas/pull/22916/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvdGVybWluYWwucHk=) | `21.25% <0%> (ø)` | :arrow_up: |
| [pandas/io/packers.py](https://codecov.io/gh/pandas-dev/pandas/pull/22916/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3BhY2tlcnMucHk=) | `88.04% <0%> (ø)` | :arrow_up: |
| [pandas/io/sas/sas\_xport.py](https://codecov.io/gh/pandas-dev/pandas/pull/22916/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/22916/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNyZWFkZXIucHk=) | `86.2% <0%> (ø)` | :arrow_up: |
| [pandas/io/parsers.py](https://codecov.io/gh/pandas-dev/pandas/pull/22916/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/22916/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvY29uc29sZS5weQ==) | `75.75% <75%> (ø)` | :arrow_up: |

------

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

@JustinZhengBC any reason to close this PR? I think it was ready to be merged.
I was trying to get Travis to rebuild by closing and reopening but it turns out that doesn’t work if I previously deleted my fork (which I did after accidentally pushing to master). I have resubmitted it as referenced above.