[Python-3000] bug in i/o module buffering?

Guido van Rossum guido at python.org
Mon Oct 29 19:07:21 CET 2007


__index__() converts an "int-like" object to an int. This is needed to
make sure that e.g. numpy integral scalars can be used for indexing.
For a regular int it doesn't matter, so here it's a red herring.

I'm asking about b because the error message "TypeError: 'slice'
object does not support item deletion" would suggest that b is a slice
object. I agree that doesn't sound very likely given the code
though... :-( Could you step through this using pdb and investigate
some more? Perhaps there's a refcount error somewhere in the C code?

--Guido

2007/10/27, Bill Janssen <janssen at parc.com>:
> From RawIOBase.read().  What's __index__() do?
>
>         b = bytes(n.__index__())
>
> > More interesting is, what's b?
> >
> > 2007/10/27, Bill Janssen <janssen at parc.com>:
> > > In the following, 'n' is equal to 0 (read from a non-blocking socket).
> > > Is this a bug in the I/O module buffering?
> > >
> > > Bill
> > >
> > > Traceback (most recent call last):
> > >   File "/local/python/3k/src/Lib/SocketServer.py", line 222, in handle_request
> > >     self.process_request(request, client_address)
> > >   File "/local/python/3k/src/Lib/SocketServer.py", line 241, in process_request
> > >     self.finish_request(request, client_address)
> > >   File "/local/python/3k/src/Lib/SocketServer.py", line 254, in finish_request
> > >     self.RequestHandlerClass(request, client_address, self)
> > >   File "/local/python/3k/src/Lib/SocketServer.py", line 522, in __init__
> > >     self.handle()
> > >   File "/local/python/3k/src/Lib/BaseHTTPServer.py", line 330, in handle
> > >     self.handle_one_request()
> > >   File "/local/python/3k/src/Lib/BaseHTTPServer.py", line 313, in handle_one_request
> > >     self.raw_requestline = self.rfile.readline()
> > >   File "/local/python/3k/src/Lib/io.py", line 391, in readline
> > >     b = self.read(nreadahead())
> > >   File "/local/python/3k/src/Lib/io.py", line 377, in nreadahead
> > >     readahead = self.peek(1, unsafe=True)
> > >   File "/local/python/3k/src/Lib/io.py", line 778, in peek
> > >     current = self.raw.read(to_read)
> > >   File "/local/python/3k/src/Lib/io.py", line 455, in read
> > >     del b[n:]
> > > TypeError: 'slice' object does not support item deletion
> > > ----------------------------------------
> > >
> > > _______________________________________________
> > > Python-3000 mailing list
> > > Python-3000 at python.org
> > > http://mail.python.org/mailman/listinfo/python-3000
> > > Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org
> > >
> >
> >
> > --
> > --Guido van Rossum (home page: http://www.python.org/~guido/)
>
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list