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

Removed unnecessary string length check #7560

Merged
merged 1 commit into from
Dec 21, 2023

Conversation

radarhere
Copy link
Member

#7244 added _string_length_check() in several locations, including TransposedFont.getlength().

Pillow/src/PIL/ImageFont.py

Lines 711 to 716 in 28c173f

def getlength(self, text, *args, **kwargs):
if self.orientation in (Image.Transpose.ROTATE_90, Image.Transpose.ROTATE_270):
msg = "text length is undefined for text rotated by 90 or 270 degrees"
raise ValueError(msg)
_string_length_check(text)
return self.font.getlength(text, *args, **kwargs)

However, getlength() is immediately called after the check, which itself calls _string_length_check().

So this check is unnecessary and can be removed.

@hugovk hugovk merged commit 0331d9d into python-pillow:main Dec 21, 2023
56 checks passed
@radarhere radarhere deleted the string_length_check branch December 21, 2023 11:00
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