Message 357737 - Python tracker (original) (raw)
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.