[Python] Fix handling of zero-width types returned by a custom Demangler#8100
[Python] Fix handling of zero-width types returned by a custom Demangler#8100
Conversation
CouleeApps
left a comment
There was a problem hiding this comment.
... I'm surprised python makes the leap from truthiness -> non zero length. What ever happened to "Explicit is better than implicit."
The bugfix change itself is good but the test you wrote (in the private repo) might be better placed in test_demangler.py and likely doesn't need all the extra scaffolding.
|
I'll rework my test. I somehow entirely overlooked the existence of that file 😅 Python has treated empty lists as false since very early versions, and they expanded that behavior to user defined types via |
|
I don't think we should make any changes to |
9304762 to
424dc72
Compare
Explicitly test the type against
Nonerather than testing for truthiness. This ensures that zero-width types returned by a custom demangler will be applied.Fixes #8099.
For some reason
Typeimplements__len__and returnsself.width. This causes zero-width types, such as function types, to be considered False. This is somewhere on the spectrum of unnecessarily confusing and just plain wrong.