-
Notifications
You must be signed in to change notification settings - Fork 487
fix iterable check for Python 3.13.4 and newer #3855
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
Conversation
Fix the `feaLib/ast.py` snippet used to check whether a type is iterable to work correctly with Python 3.13.4. The snippet wrongly assumed that a generator expression will raise immediately when the RHS of `in` is not iterable. This is no longer the case with Python 3.13.4, and such a generator only raises when you actually start iterating. Use a plain `for` expression to start iterating and catch the problem more reliably. Fixes fonttools#3854
While this is a bug with Python 3.13.4, I'm inclined to accept this fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would consume the first item if lookup already is an iterable. That doesn't happen in the actual code, though.
I wonder if we should do something like this instead:
if not isinstance(lookup, typing.Sequence):
self.lookups[i] = [lookup]
Hmm, good point, I've assumed the type will involve only containers and not iterators. I don't know how reliable |
The exact equivalent to the original generator expression is |
Switch to using `iter(lookup)` as suggested by @dscorbett as the exact equivalent of the original expression. Most importantly, this avoids incidentally taking the first item off `lookup` if it is an iterator.
Updated to use |
Can this be merged? I'm seeing bot fails due to this I believe: |
Thank you! |
Thank you. Somehow I missed this. I also just tagged a new release, should get published soon once the CI completes. |
Fix the
feaLib/ast.py
snippet used to check whether a type is iterable to work correctly with Python 3.13.4. The snippet wrongly assumed that a generator expression will raise immediately when the RHS ofin
is not iterable. This is no longer the case with Python 3.13.4, and such a generator only raises when you actually start iterating. Use a plainfor
expression to start iterating and catch the problem more reliably.Fixes #3854