On 1/8/21 4:31 PM, Mats Wichmann wrote:
Someone reported a testsuite break on stuff I work on (scons) with 3.10a4, and it looks similar to this which appears in the changelog at
https://docs.python.org/3.10/whatsnew/changelog.html#changelog
bpo-23898: Fix inspect.classify_class_attrs() to support attributes with overloaded __eq__ and __bool__. Patch by Mike Bayer.
Except when I go look at that BPO issue, it's old - closed 2015. Is this appearing in the 3.10 changelog in error? Sorry - confused !!!
okay, that was silly, I didn't realize the changelog was cumulative over many versions, so that entry was not for 3.10 at all (teach me to do searching in browser window, where it just flies right past any section headings so I miss it was for a different version :) ).
The test in question does indeed touch a class which overrides __bool_ in order to raise an exception (to say "don't do that"), and in the test run the (expected) exception is not raised.
So updated information: the test in question is checking if a class (A) has an attribute using a truth test, where the attribute's value is an instance of another class (B) and expecting that that will cause the __bool__ method to be called. [aside: this test is done to validate that a class which really doesn't want this kind of test indeed rejects it] That apparently no longer happens, if it's wrapped in a try block ??? Distilled down to simple case: class A: pass class B: def __bool__(self): raise AttributeError("don't do that!") a = A() b = B() a.b = b # expect this to cause b.__bool__ to be called if a.b: print("Found it!") and it raises the exception. But when protected: try: if a.b: pass except AttributeError: print("Got expected exception") else: print("Missed expected exception") it won't trigger. But if I add a "real" statement in the block following the "if", then it's back to the pre-3.10 behavior of calling __bool__: try: if a.b: dummy = True except AttributeError: print("Got expected exception") else: print("Missed expected exception") Any thoughts on this?