Skip to content

Error when processing file mode string #1425

@lobis

Description

@lobis

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions