write function call _io_BufferedWriter_write_impl twice?
songofacandy at gmail.com
Thu May 30 07:26:48 EDT 2019
The second _io_BufferedWriter_write_impl call is for show warning like
"ResourceWarning: unclosed file <_io.BufferedRandom name='myfile'>"
Try `f.close()`, or `with open(...)`.
On Thu, May 30, 2019 at 12:03 PM Windson Yang <wiwindson at gmail.com> wrote:
> My script looks like this:
> f = open('myfile', 'a+b')
> And I also add a `printf` statement in the _io_BufferedWriter_write_impl
> static PyObject * _io_BufferedWriter_write_impl(buffered *self,
> Py_buffer *buffer)
> /*[clinic end generated code: output=7f8d1365759bfc6b
> printf("call write_impl\n");
> PyObject *res = NULL;
> Py_ssize_t written, avail, remaining;
> Py_off_t offset;
> After I compiled then run my script. I found _io_BufferedWriter_write_impl
> been called twice which I expected only once. The second time it changed
> self->pos to an unexpected value too.
Inada Naoki <songofacandy at gmail.com>
More information about the Python-list