This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xiang.zhang
Recipients Igor Kozyrenko (ikseek), xiang.zhang
Date 2017-06-02.16:44:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1496421890.29.0.106818852135.issue30554@psf.upfronthosting.co.za>
In-reply-to
Content
Actually the docs says "This attribute is available when using the buffered I/O classes from the io module", which means it's not always available since it depends on an inner field set or not.

It's just like Python code:

>>> class CW:
...     def __get__(self, obj, objtype):
...             if obj._written:
...                     return obj._written
...             else:
...                     raise AttributeError("characters_written")
...     def __set__(self, obj, val):
...             obj._written = val
... 
>>> class MyOSError:
...     characters_written = CW()
...     def __init__(self):
...             self._written = False
... 
>>> dir(MyOSError())
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_written', 'characters_written']
>>> MyOSError().characters_written
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 6, in __get__
AttributeError: characters_written
History
Date User Action Args
2017-06-02 16:44:50xiang.zhangsetrecipients: + xiang.zhang, Igor Kozyrenko (ikseek)
2017-06-02 16:44:50xiang.zhangsetmessageid: <1496421890.29.0.106818852135.issue30554@psf.upfronthosting.co.za>
2017-06-02 16:44:50xiang.zhanglinkissue30554 messages
2017-06-02 16:44:49xiang.zhangcreate