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

PloneBatch: define __bool__ as copy of __nonzero__. #3175

Merged
merged 1 commit into from
Sep 16, 2020

Conversation

mauritsvanrees
Copy link
Sponsor Member

Python 2 calls __nonzero__, Python 3 calls __bool__.
Since __bool__ was not defined, Python 3 called len(batch) instead, leading to these warnings when a template has code like tal:condition="batch":

Products/PageTemplates/Expressions.py:253: DeprecationWarning: Using len() is deprecated.
Use the `length` attribute for the size of the current page, which is what we return now.
Use the `sequence_length` attribute for the size of the entire sequence. 
  return bool(value)

(I now think we should undo this deprecation, but that is something for a different issue.)

@mister-roboto

This comment has been minimized.

Python 2 calls __nonzero__, Python 3 calls __bool__.
@mauritsvanrees
Copy link
Sponsor Member Author

@jenkins-plone-org please run jobs

@mauritsvanrees mauritsvanrees merged commit 728b3e4 into 5.2.x Sep 16, 2020
@mauritsvanrees mauritsvanrees deleted the maurits/batch-bool branch September 16, 2020 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants