Berker Peksag added the comment:
Changing the value of mode also changes its repr. This seems like a bug to me.
It's probably too late to change TextIOWrapper.__repr__(). I think this needs
to be discussed on python-dev first.
>>> f = open("README.rst")
>>> f
<_io.TextIOWrapper name='README.
Nitish added the comment:
It appears some files like Lib/tokenize.py changes the mode of TextIOWrapper:
text = TextIOWrapper(buffer, encoding, line_buffering=True)
text.mode = 'r'
setting of mode via _PyObject_SetAttrId(wrapper, &PyId_mode, modeobj) is done
in some source file
R. David Murray added the comment:
That isn't a bug. Python doesn't protect you from doing the wrong thing, in
general. On the other hand, it might be a worthwhile improvement to make it
read-only in this case. Especially since, as you point out, other seemingly
similar attributes of this
New submission from Марат Нагаев :
Hey guys,
I find bug in Python.
If you'll try to file stream using open function you can edit file mode:
Watch git:
https://gist.github.com/nagayev/7d17ead7b3bc2b06f2445fb5d9122a5c
In fact,mode don't changed,so mode shoul be constant like a encoding of the
file