Re: [Python-Dev] Why does IOBase.__del__ call .close?

2014-06-13 Thread Benjamin Peterson
On Fri, Jun 13, 2014, at 20:04, Nikolaus Rath wrote: > Benjamin Peterson writes: > > On Thu, Jun 12, 2014, at 18:06, Nikolaus Rath wrote: > >> Consider this simple example: > >> > >> $ cat test.py > >> import io > >> import warnings > >> > >> class StridedStream(io.IOBase): > >> def __init_

Re: [Python-Dev] Why does IOBase.__del__ call .close?

2014-06-13 Thread Nikolaus Rath
Benjamin Peterson writes: > On Thu, Jun 12, 2014, at 18:06, Nikolaus Rath wrote: >> Consider this simple example: >> >> $ cat test.py >> import io >> import warnings >> >> class StridedStream(io.IOBase): >> def __init__(self, name, stride=2): >> super().__init__() >> self.fh

Re: [Python-Dev] Why does IOBase.__del__ call .close?

2014-06-12 Thread Benjamin Peterson
On Thu, Jun 12, 2014, at 18:06, Nikolaus Rath wrote: > Consider this simple example: > > $ cat test.py > import io > import warnings > > class StridedStream(io.IOBase): > def __init__(self, name, stride=2): > super().__init__() > self.fh = open(name, 'rb') > self.stri

Re: [Python-Dev] Why does IOBase.__del__ call .close?

2014-06-12 Thread Nikolaus Rath
Benjamin Peterson writes: > On Wed, Jun 11, 2014, at 17:11, Nikolaus Rath wrote: >> MRAB writes: >> > On 2014-06-11 02:30, Nikolaus Rath wrote: >> >> Hello, >> >> >> >> I recently noticed (after some rather protacted debugging) that the >> >> io.IOBase class comes with a destructor that calls sel

Re: [Python-Dev] Why does IOBase.__del__ call .close?

2014-06-11 Thread Benjamin Peterson
On Wed, Jun 11, 2014, at 17:11, Nikolaus Rath wrote: > MRAB writes: > > On 2014-06-11 02:30, Nikolaus Rath wrote: > >> Hello, > >> > >> I recently noticed (after some rather protacted debugging) that the > >> io.IOBase class comes with a destructor that calls self.close(): > >> > >> [0] nikratio@v

Re: [Python-Dev] Why does IOBase.__del__ call .close?

2014-06-11 Thread Nikolaus Rath
MRAB writes: > On 2014-06-11 02:30, Nikolaus Rath wrote: >> Hello, >> >> I recently noticed (after some rather protacted debugging) that the >> io.IOBase class comes with a destructor that calls self.close(): >> >> [0] nikratio@vostro:~/tmp$ cat test.py >> import io >> class Foo(io.IOBase): >>

Re: [Python-Dev] Why does IOBase.__del__ call .close?

2014-06-11 Thread Nick Coghlan
On 11 Jun 2014 12:31, "Antoine Pitrou" wrote: > > Le 10/06/2014 21:30, Nikolaus Rath a écrit : > >> >> For me, having __del__ call close() does not qualify as a reasonable >> default implementation unless close() is required to be idempotent >> (which one could deduce from the documentation if one

Re: [Python-Dev] Why does IOBase.__del__ call .close?

2014-06-10 Thread Antoine Pitrou
Le 10/06/2014 21:30, Nikolaus Rath a écrit : For me, having __del__ call close() does not qualify as a reasonable default implementation unless close() is required to be idempotent (which one could deduce from the documentation if one tries to, but it's far from clear). close() should indeed b

Re: [Python-Dev] Why does IOBase.__del__ call .close?

2014-06-10 Thread MRAB
On 2014-06-11 02:30, Nikolaus Rath wrote: Hello, I recently noticed (after some rather protacted debugging) that the io.IOBase class comes with a destructor that calls self.close(): [0] nikratio@vostro:~/tmp$ cat test.py import io class Foo(io.IOBase): def close(self): print('clos

[Python-Dev] Why does IOBase.__del__ call .close?

2014-06-10 Thread Nikolaus Rath
Hello, I recently noticed (after some rather protacted debugging) that the io.IOBase class comes with a destructor that calls self.close(): [0] nikratio@vostro:~/tmp$ cat test.py import io class Foo(io.IOBase): def close(self): print('close called') r = Foo() del r [0] nikratio@vostro