Improve our support for hasattr() (#20914)
Our support for `hasattr()` is quite fragile/limited. In particular, it
didn't work if there was an existing narrowing in the current frame. For
`--allow-redefinition-new` this was a critical hit, since it can do
`binder.put()` on initial assignment, thus making our `hasattr()`
support non-functional.
This (somewhat ad-hoc) fix seems to restore parity for `hasattr()`
support. Also it may even improve `hasattr()` support n regular mode in
some edge cases