fsspec / fsspec/filesystem_spec
Error when processing file mode string
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 490
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 38
Description
In the memory filesystem there is an error if you try to open it with r+b mode saying this mode is not supported.
However this mode is apparently supported (https://github.com/fsspec/filesystem_spec/blob/master/fsspec/implementations/memory.py#L178).
What I think is happening is that the mode=r+b(or mode=rb+) argument is being processed and transformed internally to r+b and then the comparison to rb+ fails.
(I assume that it should work for any order for the characters in the mode string: rb+ or r+b).
Reproducer:
import fsspec
uri = "memory://path/file"
open_file = fsspec.open(uri, mode="rb+") # r+b doesn't work either
assert open_file.mode == "rb+"
file = open_file.open() # raises ValueError
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with fsspec/implementations/memory.py around line 178 and run the reproducer from the issue for both rb+ and r+b modes. Trace where the mode is normalized before the support check; done means both equivalent mode strings open successfully without the unsupported-mode error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100