BUG: read_csv/table raising when sys.setprofile used
- [x] closes #41069
- [x] tests added / passed
- [x] Ensure all linting tests pass, see [here](https://pandas.pydata.org/pandas-docs/dev/development/contributing.html#code-standards) for how to run them
- [x] whatsnew entry

According to https://docs.python.org/3/library/functions.html#locals, `locals()` should not be modified. AFAICT these are the only places `locals()` is used in this way without copying.