Infer compression from non-string paths
Currently, `compression='infer'` only works on paths that are strings. However, pandas supports non-string paths, such as `pathlib.Path` objects. This PR adds support for inferring compression for all path types (for io interfaces that use `io.common._infer_compression`).

## Checklist

- [x] passes ``git diff upstream/master -u -- "*.py" | flake8 --diff``
- [x] No issue opened
- [x] tests added / passed
- [x] whatsnew entry
