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

Fix an issue with the new Pillow update #462

Merged
merged 1 commit into from
Oct 16, 2023

Conversation

njooma
Copy link
Member

@njooma njooma commented Oct 16, 2023

Pillow pulled some nonsense by making a breaking change in a minor version. Oops on them. Panic! at the Robot Factory.

@njooma njooma requested a review from a team as a code owner October 16, 2023 16:50
@njooma njooma requested review from maximpertsov, cheukt and benjirewis and removed request for a team October 16, 2023 16:50
@@ -55,7 +55,7 @@ def _open(self):
width = int.from_bytes(header[4:8], "big")
height = int.from_bytes(header[8:12], "big")
self._size = width, height
self.mode = "RGBA"
self._mode = "RGBA"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean from the release notes:

The convert method is the correct way to change an image's mode.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that's for existing images, but not for creating our own image decoder. The documentation states

An image plugin should contain a format handler derived from the PIL.ImageFile.ImageFile base class. This class should provide an _open method, which reads the file header and set at least the internal _size and _mode attributes so that mode and size are populated.

so we should be safe setting these private attrs here. (famous last words, given this PR)

Copy link
Member

@benjirewis benjirewis Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah gotcha; yeah they set self._mode in their example, too.

@@ -55,7 +55,7 @@ def _open(self):
width = int.from_bytes(header[4:8], "big")
height = int.from_bytes(header[8:12], "big")
self._size = width, height
self.mode = "RGBA"
self._mode = "RGBA"
Copy link
Member

@benjirewis benjirewis Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah gotcha; yeah they set self._mode in their example, too.

@@ -338,6 +338,9 @@ async def model_attributes(self) -> Board.Attributes:
async def set_power_mode(self, **kwargs):
raise NotImplementedError()

async def write_analog(self, pin: str, value: int, *, timeout: float | None = None, **kwargs):
raise NotImplementedError()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] how is this related to the mode change? just a drive-by?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup -- docs tests were failing because of a missed update to the example server. My bad, should've noted [flyby]

@njooma njooma merged commit b8cc2b2 into viamrobotics:rc-0.8.0 Oct 16, 2023
1 check passed
@njooma njooma deleted the hotfix/pillow-update branch October 16, 2023 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants