REGR: to_stata tried to remove file before closing it by twoertwein · Pull Request #39202 · pandas-dev/pandas (original) (raw)
I think to_stata
is the only to_*
method that tries to remove created files in case of an error. Is that something other methods should also try to do?
I'm not sure but I could imagine that __exit__
in IOHandles
might be able to determine whether an exception from within pandas's io part was raised: if yes, try to delete the files. This would probably only cover local files (no fsspec strings) and only work for to_*
methods that use with get_handles(...)
(some methods have to use it without the context manager and explicitly call close
- IOHandles
wouldn't know whether an exception occurred.