[issue30554] Inaccessible attribute characters_written on OSError instances

R. David Murray report at bugs.python.org
Fri Jun 2 13:42:10 EDT 2017


R. David Murray added the comment:

That's actually a very good question.  hasattr returns False, but is it supposed to be an invariant that if dir returns a string hasattr should return True and getattr should not return AttributeError?  (Well, it might raise AttributeError from inside the attribute, but the attribute itself should be "real".)  Or to put it the other way, if hasattr returns False, should it be an invariant that dir does not list that attribute name?

This may be a question for python-dev, and the answer may well be that we do *not* want to suggest that such an invariant should be expected.  (We of course don't enforce such things, but we do make them hold true in the stdlib if we establish them).  However, it is certainly a surprising behavior, and Python *generally* tries to avoid such surprises.

This may have already been discussed and decided at some previous point, so someone should do some docs and archive searching about it first :)

----------
nosy: +r.david.murray

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30554>
_______________________________________


More information about the Python-bugs-list mailing list