Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "c2pa-python"
version = "0.32.11"
version = "0.32.12"
requires-python = ">=3.10"
description = "Python bindings for the C2PA Content Authenticity Initiative (CAI) library"
readme = { file = "README.md", content-type = "text/markdown" }
Expand Down
18 changes: 15 additions & 3 deletions src/c2pa/c2pa.py
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,17 @@ def read_callback(ctx, data, length):
if not data or length <= 0:
return -1

buffer = self._file_like_stream.read(length)
stream = self._file_like_stream
readinto = getattr(stream, "readinto", None)
if readinto is not None:
# Most streams have readinto
buf = (ctypes.c_char * length).from_address(
ctypes.addressof(data.contents))
n = readinto(buf)
return n if n else 0

# Fallback for streams without readinto.
buffer = stream.read(length)
if not buffer: # EOF
return 0

Expand Down Expand Up @@ -1846,8 +1856,10 @@ def seek_callback(ctx, offset, whence):
if not self._initialized or self._closed:
return -1
try:
file_stream.seek(offset, whence)
return file_stream.tell()
# Fall back to tell() only for stream objects that do not
# return the new absolute position and return None.
pos = file_stream.seek(offset, whence)
return pos if pos is not None else file_stream.tell()
except Exception:
return -1

Expand Down
Loading