Irit Katriel <iritkatr...@yahoo.com> added the comment:

The mode string is calculated here: 
https://github.com/python/cpython/blob/master/Modules/_io/fileio.c#L1055

and is based on these four values in the fileio struct:

    unsigned int created : 1;
    unsigned int readable : 1;
    unsigned int writable : 1;
    unsigned int appending : 1;

This is not enough information to distinguish between r+ and w+. That 
distinction was lost in _io_FileIO___init___impl, where it specified the flags 
that went into creating fd, but these flags are not saved.

The bit fields in this struct add up to 7 bits, so it seems possible to fix 
this if another bit is allocated for this purpose.

If it's not worth it, then the documentation needs to change a little.

----------
nosy: +iritkatriel

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

Reply via email to