Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102915 > unrolled thread

Re: ftplib throws: IndexError: tuple index out of range

Started byPeter Otten <__peter__@web.de>
First post2016-02-14 14:40 +0100
Last post2016-02-14 14:40 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: ftplib throws: IndexError: tuple index out of range Peter Otten <__peter__@web.de> - 2016-02-14 14:40 +0100

#102915 — Re: ftplib throws: IndexError: tuple index out of range

FromPeter Otten <__peter__@web.de>
Date2016-02-14 14:40 +0100
SubjectRe: ftplib throws: IndexError: tuple index out of range
Message-ID<mailman.107.1455457249.22075.python-list@python.org>
Antoon Pardon wrote:

> I have written a small backup program, that uses ftplib to make
> remote backups. However recentely the program starts to regularly
> raise IndexErrors, as far as I can see the problem is in socket.py
> Can anyone shed some light?
> 
> This is the traceback:

[...]

>   File "/usr/lib/python2.7/socket.py", line 478, in readline
>     if e.args[0] == EINTR:
> IndexError: tuple index out of range

The offending line seems to be part of

                try:
                    data = self._sock.recv(self._rbufsize)
                except error, e:
                    if e.args[0] == EINTR:
                        continue
                    raise


> Locals by frame, innermost last

[...]

> Frame readline in /usr/lib/python2.7/socket.py at line 478
>                  buf = <cStringIO.StringO object at 0x7ff8c5d40298>
>              buf_len = 0
>                    e = timeout()
>                 self = <socket._fileobject object at 0x7ff8c7b75b50>
>                 size = 8193

It looks like the actual error is socket.timeout which is probably raised 
from somewhere inside the stdlib without args. 

I think this is a bug in socket.py; the error handler should special-case 
with either

try:
     ...
except timeout, e:
    raise
except error, e:
    ...


or

try:
    ...
except error, e:
    if e.args and e.args[0] == EINTR:
        continue
    raise

You will still have to find the cause and handle the effects of the timeout.

PS: How did you produce the overview over the local variables? That looks 
nice.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web