This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author philiprowlands
Recipients effbot, gvanrossum, philiprowlands, rhettinger, scoder, serhiy.storchaka
Date 2019-12-03.00:05:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1575331520.62.0.661803438101.issue38941@roundup.psfhosted.org>
In-reply-to
Content
I went digging through the archives, made more interesting as elementtree was imported into the standard library.

AFAICT, the FutureWarning for __bool__ (or __nonzero__ in py2) appeared circa 2007-06 in version 1.3a2:
http://svn.effbot.org/public/tags/elementtree-1.3a3-20070912/CHANGES

- Added future warnings for "if e" (use explicit len(e) or is None
  test) and "e.getchildren()" (use list(e) or iteration).

The docs are still there, warning about the pitfalls and suggesting "This behaviour is likely to change somewhat in ElementTree 1.3."
https://effbot.org/zone/element.htm#truth-testing

12 years on, it has not, but what was the intended change (+effbot for possible context)??

I assumed on first reading that the plan was to switch bool(Element) to return True, but others have pointed out the inconsistency with len(), or having __bool__() raise an exception.

My 2c would be to steer devs away from using bool(Element) as a final step, i.e. keep the existing True/False definition, warts and all, but raise a SyntaxWarning (RuntimeWarning?) with a similar message to the current FutureWarning.
History
Date User Action Args
2019-12-03 00:05:20philiprowlandssetrecipients: + philiprowlands, gvanrossum, effbot, rhettinger, scoder, serhiy.storchaka
2019-12-03 00:05:20philiprowlandssetmessageid: <1575331520.62.0.661803438101.issue38941@roundup.psfhosted.org>
2019-12-03 00:05:20philiprowlandslinkissue38941 messages
2019-12-03 00:05:19philiprowlandscreate