Skip to content

Commit

Permalink
utils.is_buffer: nits
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Mar 19, 2023
1 parent 5362ef3 commit 6df5b7c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/pypdfium2/_helpers/_internal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ def set_callback(struct, fname, callback):


def is_buffer(buf, spec="r"):
methods = ()
methods = []
assert set(spec).issubset(set("rw"))
if "r" in spec:
methods += ("seek", "tell", "read", "readinto")
methods += ["seek", "tell", "read", "readinto"]
if "w" in spec:
methods += ("write", )
methods += ["write"]
return all(callable(getattr(buf, a, None)) for a in methods)


Expand Down

0 comments on commit 6df5b7c

Please sign in to comment.