Mark Williams added the comment:

Python's test suite may test the current behavior but that does not lessen
the problem.

I gave an example of apparently correct code that fails (that was actually
encountered by a Python user) in my original description.  Another such
example: you cannot duplicate a file object -- same path, same mode --- and
be sure that the duplicate is a true duplicate.  Data corruption could
occur in application code if the duplicated file were opened "rb+" instead
of "wb+", as the duplicate would not truncate existing data.

Another way to think about the problem is accuracy of intent.  The mode
attribute on file objects can be incorrect, and by "incorrect" I mean "not
describe the mode under which the file was opened."  Why have a mode
attribute at all, then?  I, for one, would prefer *no* mode attribute to
one that's sometimes incorrect.  But a correct one is even better!

On Sat, Oct 10, 2015 at 1:27 AM, Xiang Zhang <rep...@bugs.python.org> wrote:

>
> Xiang Zhang added the comment:
>
> I think Mark is right. Since wb+ and rb+ have different behaviours they
> should be treat separately.
>
> But this behaviour treating wb+ and rb+ as the same is well tested and
> seems to intended to do so.
>
> ----------
> nosy: +xiang.zhang
>
> _______________________________________
> Python tracker <rep...@bugs.python.org>
> <http://bugs.python.org/issue25341>
> _______________________________________
>

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25341>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to