[issue9858] Python and C implementations of io are out of sync

Benjamin Peterson report at bugs.python.org
Wed Sep 15 17:51:10 CEST 2010


Benjamin Peterson <benjamin at python.org> added the comment:

2010/9/15 Daniel Stutzbach <report at bugs.python.org>:
>
> Daniel Stutzbach <daniel at stutzbachenterprises.com> added the comment:
>
>> These attributes exist; they're just not properties.
>
> Yes, I see.  They're added to the instance in the constructor, so they don't exist as attributes of the class.  Also in that category:
>
> BlockingIOError python is missing: ['characters_written']
>
> That leaves:
>
> RawIOBase C is missing: ['readinto', 'write']
> StringIO C is missing: ['name']
> StringIO python is missing: ['__getstate__', '__setstate__']
> BytesIO python is missing: ['__setstate__']

I'm not sure if this pickling stuff matters as long as they both pickle.

>
> The Python version of StringIO throws an AttributeException on the .name attribute.  It's a property inherited from the TextIOWrapper.  Effectively, TextIOWrapper provides the .name attribute if the object that it's wrapping provides the .name attribute.  This behavior is undocumented.
>
> Is that reasonable behavior?  Or should TextIOWrapper define .name always and return some suitable value if the wrapped object doesn't define .name? (e.g., None)

Yes, all the code expects an AttributeError on name is it's not
present. For example, FileIO only sets its name attribute if it is
passed a filename and not an fd.

----------

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


More information about the Python-bugs-list mailing list