MNT: be more careful about disk I/O failures when writing font cache#28541
Conversation
WeatherGod
left a comment
There was a problem hiding this comment.
This makes sense to me. Are all file-related errors now OSError? Just double-checking.
|
I checked the |
Yes. https://docs.python.org/3/library/exceptions.html#exception-hierarchy |
timhoffm
left a comment
There was a problem hiding this comment.
Take or leave my suggestions. May self merge then.
| # 2. import matplotlib which makes sure it exists | ||
| # 3. get the cache dir (where we check it is writable) | ||
| # 4. make it not writable | ||
| # 5. try to write into it via font manager |
There was a problem hiding this comment.
| # 5. try to write into it via font manager | |
| # 5. try to write into it via font manager | |
| # 6. Check that we do not raise even though 5. cannot work |
There was a problem hiding this comment.
Optional: Check that the log warning is emitted.
There was a problem hiding this comment.
I'm going to pass on adding a check for the logging. I don't think we do that systematically currently and because the log emission happens in the sub-process it would take a fair amount of work to check (I think something like the tests for blocking where we print something and them search for the string in stdout).
The locker works by writing a file to disk. This can also fail so make sure we can still import in that case. Closes matplotlib#28538
ba06dc6 to
40f642f
Compare
|
The windows failures were real, but fortunately we have hit them before and I could copy the fix (Python won't start on windows with an empty env because all of the random number APIs fail). |
|
Self merging per Tim's comment. |
…lures when writing font cache
…541-on-v3.9.x Backport PR #28541 on branch v3.9.x (MNT: be more careful about disk I/O failures when writing font cache)
The locker works by writing a file to disk. This can also fail so make sure we can still import in that case.
Closes #28538
The only way I could think to test this is very synthetic and requires messing with the file system at in between importing the top level module and font_manager. Still not sure how the OP drove their system to expose this issue. I think it has not come up before because if the directory is not writable we detect that and bail to asking for a temporary directory to work with.
PR checklist