IndexError: pop from empty list

Peter Otten __peter__ at web.de
Fri May 16 04:15:13 EDT 2014


chris at freeranger.com wrote:

> No, that was pretty much what I was looking for.  If anyone has an answer
> to the deeper question, that would be icing on the cake.
> 
> What is interesting is that usually the traceback shows the line of code
> that I invoke which, deep inside a library I'm using, has generated an
> error.  In this case I don't know which of my commands has spawned the
> error.
> 
> I can experiment, I suppose, with putting a try/catch around suspected
> lines of code...

It looks like the xbee library is responsible for reading the right amount 
of bytes and then fails to parse them properly.

So it is possible (even likely I think) that you have run into a bug in the 
library.

A report to the author/maintainer should be in order. Of course it would 
help if you can find a way to reproduce the error. One way to do that is to 
modify the code

    def _parse_samples(self, io_bytes):
        try:
            ... # original code of the method
        except IndexError:
            # replace path with something that makes sense on your system
            with open("/path/to/io_bytes.data", "wb") as f:
                f.write(io_bytes)
            raise
 
wait until the error occurs again and then send the contents of the 
io_bytes.data file along with your bug report.




More information about the Python-list mailing list