Skip to content
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

Added logging to TiffImagePlugin fixIFD() #8568

Merged
merged 2 commits into from
Jan 16, 2025
Merged

Conversation

radarhere
Copy link
Member

Alternative to #8316

For this TiffImagePlugin fixIFD() code

if is_local:
self._fixOffsets(count, field_size)
self.f.seek(cur_pos + 4)
else:
self.f.seek(offset)
self._fixOffsets(count, field_size)
self.f.seek(cur_pos)

the original PR suggests catching RunTimeErrors ("not implemented", "wrote only {bytes_written} bytes but wanted {expected}" or "offset is not supported") and re-raising it with tag info appended to the error message.

I think the way this is done in the rest of TiffImagePlugin is to use logger.debug().

tagname = TiffTags.lookup(tag, self.group).name
typname = "ifd" if is_ifd else TYPES.get(typ, "unknown")
msg = f"save: {tagname} ({tag}) - type: {typname} ({typ})"
msg += " - value: " + (
"<table: %d bytes>" % len(data) if len(data) >= 16 else str(values)
)
logger.debug(msg)

So this PR uses logger.debug() instead.

src/PIL/TiffImagePlugin.py Outdated Show resolved Hide resolved
Co-authored-by: Hugo van Kemenade <[email protected]>
@hugovk hugovk merged commit bff83cf into python-pillow:main Jan 16, 2025
51 of 53 checks passed
@radarhere radarhere deleted the fixifd branch January 16, 2025 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants