-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix inconsistent file mode formatting and comparison (rb+
changed to r+b
)
#1426
Conversation
@martindurant after starting this PR I realised that there are different places where the mode is specified (not everything goes through the OpenFile.enter) (This is why the new test fails). I could normalize the mode everywhere but it's a bit messy. Do you agree on the need to normalize (sort) the file mode string? I think it's dangerous to do string comparisons inside the file system against some reference modes ("wb", "rb+", etc.) when these modes can be in different order (but meaning the same thing). Currently I think the only failing case is when using "+" but still I think it should be addressed (memory filesystem cannot be opened with "rb+" or "r+b" because of the reordering taking place). |
Maybe you can sprinkle |
At the end I chose not to modify how mode is processed: Instead I replaced all instances of I think it makes sense anyway that the file mode should always have |
rb+
changed to r+b
)
@martindurant this is now ready, please let me know if you any have feedback. |
python seems to agree |
Triggered by #1425
The current processing of the file mode string causes the
b
character to always be on the end of the mode e.g.rb+
becomesr+b
.However in some instances (such as in the memory file system), the valid file modes listed are not compatible with this format, for instance
rb+
is listed. This comparison will never take place given how the mode string is processed.This PR replaces all instances of
rb+
tor+b
so that this works now.