Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue15487] Correct __sizeof__ support for buffered I/O

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Jul 29, 2012, 6:10 AM

Post #1 of 13 (129 views)
Permalink
[issue15487] Correct __sizeof__ support for buffered I/O

New submission from Serhiy Storchaka:

Here is a patch that implements correct __sizeof__ for C implementation of buffered I/O files: io.BufferedReader, io.BufferedWriter and io.BufferedRandom.

----------
components: IO, Library (Lib)
messages: 166756
nosy: benjamin.peterson, hynek, pitrou, storchaka, stutzbach
priority: normal
severity: normal
status: open
title: Correct __sizeof__ support for buffered I/O
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15487>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 29, 2012, 6:31 AM

Post #2 of 13 (123 views)
Permalink
[issue15487] Correct __sizeof__ support for buffered I/O [In reply to]

Hynek Schlawack added the comment:

There is no patch.

----------
stage: -> needs patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15487>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 29, 2012, 6:56 AM

Post #3 of 13 (123 views)
Permalink
[issue15487] Correct __sizeof__ support for buffered I/O [In reply to]

Changes by Serhiy Storchaka <storchaka [at] gmail>:


----------
keywords: +patch
Added file: http://bugs.python.org/file26575/bufferedio_sizeof.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15487>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 29, 2012, 7:44 AM

Post #4 of 13 (123 views)
Permalink
[issue15487] Correct __sizeof__ support for buffered I/O [In reply to]

Antoine Pitrou added the comment:

Instead of putting this in MiscIOTest, you could use the relevant class-specific test cases.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15487>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 29, 2012, 9:30 AM

Post #5 of 13 (123 views)
Permalink
[issue15487] Correct __sizeof__ support for buffered I/O [In reply to]

Meador Inge added the comment:

Serhiy, I didn't analyze it too in depth, but why aren't the test cases using the __sizeof__ support work you implemented for issue15467? I think these tests should be using the more exact method like your other '__sizeof__' patches.

----------
nosy: +meador.inge
stage: needs patch -> patch review

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15487>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 29, 2012, 9:33 AM

Post #6 of 13 (123 views)
Permalink
[issue15487] Correct __sizeof__ support for buffered I/O [In reply to]

Serhiy Storchaka added the comment:

> Instead of putting this in MiscIOTest, you could use the relevant
> class-specific test cases.

Thank you, good advice. Here is updated patch.

----------
Added file: http://bugs.python.org/file26579/bufferedio_sizeof-2.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15487>
_______________________________________
Attachments: bufferedio_sizeof-2.patch (2.88 KB)


report at bugs

Jul 29, 2012, 9:50 AM

Post #7 of 13 (123 views)
Permalink
[issue15487] Correct __sizeof__ support for buffered I/O [In reply to]

Serhiy Storchaka added the comment:

> Serhiy, I didn't analyze it too in depth, but why aren't the test cases
> using the __sizeof__ support work you implemented for issue15467? I think
> these tests should be using the more exact method like your other
> '__sizeof__' patches.

Because struct has not codes for Py_off_t and PyThread_type_lock.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15487>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 29, 2012, 10:07 AM

Post #8 of 13 (123 views)
Permalink
[issue15487] Correct __sizeof__ support for buffered I/O [In reply to]

Roundup Robot added the comment:

New changeset 8a02a93c803a by Antoine Pitrou in branch '3.2':
Issue #15487: Add a __sizeof__ implementation for buffered I/O objects.
http://hg.python.org/cpython/rev/8a02a93c803a

New changeset 1d811e1097ed by Antoine Pitrou in branch 'default':
Issue #15487: Add a __sizeof__ implementation for buffered I/O objects.
http://hg.python.org/cpython/rev/1d811e1097ed

----------
nosy: +python-dev

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15487>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 29, 2012, 10:12 AM

Post #9 of 13 (123 views)
Permalink
[issue15487] Correct __sizeof__ support for buffered I/O [In reply to]

Roundup Robot added the comment:

New changeset 1102e86b8739 by Antoine Pitrou in branch '2.7':
Issue #15487: Add a __sizeof__ implementation for buffered I/O objects.
http://hg.python.org/cpython/rev/1102e86b8739

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15487>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 29, 2012, 10:13 AM

Post #10 of 13 (123 views)
Permalink
[issue15487] Correct __sizeof__ support for buffered I/O [In reply to]

Antoine Pitrou added the comment:

Thanks for the patch :)

----------
resolution: -> fixed
stage: patch review -> committed/rejected
status: open -> closed

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15487>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 29, 2012, 10:45 AM

Post #11 of 13 (123 views)
Permalink
[issue15487] Correct __sizeof__ support for buffered I/O [In reply to]

Meador Inge added the comment:

On Sun, Jul 29, 2012 at 11:50 AM, Serhiy Storchaka <report [at] bugs> wrote:

>> Serhiy, I didn't analyze it too in depth, but why aren't the test cases
>> using the __sizeof__ support work you implemented for issue15467? I think
>> these tests should be using the more exact method like your other
>> '__sizeof__' patches.
>
> Because struct has not codes for Py_off_t and PyThread_type_lock.

Of course it doesn't -- those are Python specific typedefs. 'PyThread_type_lock'
is just a typedef to 'void *' and something could be figured out for 'Py_off_t'
in the support code.

Anyway, the way you are implementing the tests has the same issue as Martin pointed
out for the 'object.__sizeof__' method in issue15402. I could replace the
'buffered_sizeof' implementation with:

static PyObject *
buffered_sizeof(buffered *self, void *unused)
{
Py_ssize_t res;

res = 1;
if (self->buffer)
res += self->buffer_size;
return PyLong_FromSsize_t(res);
}

and the tests will still pass.

----------
nosy: +loewis

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15487>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 29, 2012, 10:55 AM

Post #12 of 13 (123 views)
Permalink
[issue15487] Correct __sizeof__ support for buffered I/O [In reply to]

Antoine Pitrou added the comment:

Le dimanche 29 juillet 2012 à 17:45 +0000, Meador Inge a écrit :
> Anyway, the way you are implementing the tests has the same issue as Martin pointed
> out for the 'object.__sizeof__' method in issue15402. I could replace the
> 'buffered_sizeof' implementation with:
>
> static PyObject *
> buffered_sizeof(buffered *self, void *unused)
> {
> Py_ssize_t res;
>
> res = 1;
> if (self->buffer)
> res += self->buffer_size;
> return PyLong_FromSsize_t(res);
> }
>
> and the tests will still pass.

That's true but, OTOH, I don't think it's very important. First, because
it is a rather unlikely mistake. Second, because the important thing is
to check that the internal buffer is part of the returned size, which is
what Serhiy's test checks for.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15487>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Aug 3, 2012, 8:43 AM

Post #13 of 13 (102 views)
Permalink
[issue15487] Correct __sizeof__ support for buffered I/O [In reply to]

Changes by Jesús Cea Avión <jcea [at] jcea>:


----------
nosy: +jcea

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15487>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.