question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Index out of Range.

See original GitHub issue

Hi I’m writing a script to parse an rSS feed and show the news on the display but randomly I am getting the following error message and I don’t know what can be the cause, I’m using spanish RSS feeds, maybe a character is out of the 256 ascii chars that are in the font file? How can I solve? Thank you.

 File "rss-feed.py", line 53, in main
    show_message(device, msg, fill="white", font=proportional(SINCLAIR_FONT))
  File "/usr/local/lib/python2.7/dist-packages/luma/core/legacy/__init__.py", line 77, in show_message
    w, h = textsize(msg, font)
  File "/usr/local/lib/python2.7/dist-packages/luma/core/legacy/__init__.py", line 29, in textsize
    src = [c for ascii_code in txt for c in font[ord(ascii_code)]]
  File "/usr/local/lib/python2.7/dist-packages/luma/core/legacy/font.py", line 21, in __getitem__
    bitmap = self.font[asciiCode]
IndexError: list index out of range

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jboyolicommented, Jun 28, 2017

Thanks for the fast reply. It appears randomly on other feeds but I found that this one specifically produces the error just after printing fine the phrase: “Siempre es más fácil obtener perdón que permiso” the accented a prints as blank using the font LCD and that is fine as I still have to edit the bytes to add the character to the font. http://www.bbc.com/mundo/temas/cultura/index.xml I’m using feed parser wich prints fine on the monitor but when trying to display it on the matrix it fails.

This is another one that produces the same error but not always as this is updated every 20 mins I think. http://www.eluniversal.com.mx/rss.xml

Thanks for looking in to it, much appreciated.

0reactions
jboyolicommented, Jul 11, 2017

I tested the tolerant class today and it worked fine. My Rss feeds are being displayed complete now. I will add some bitmap definitions to the fonts I want to use to the accented characters. Thanks again for your time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

List Index Out of Range – Python Error Message Solved
You'll get the Indexerror: list index out of range error when iterating through a list and trying to access an item that doesn't...
Read more >
What does the error 'list index out of range' mean?
Generally, list index out of range means means that you are providing an index for which a list element does not exist. Now,...
Read more >
Indexerror: list Index Out of Range in Python - STechies
“List index out of range” error occurs in Python when we try to access an undefined element from the list. The only way...
Read more >
What is an "index out of range" exception, and how do I fix it?
Why does this error occur? ... Because you tried to access an element in a collection, using a numeric index that exceeds the...
Read more >
Python IndexError: List Index Out of Range [Easy Fix] - Finxter
The error “list index out of range” arises if you access invalid indices in your Python list. For example, if you try to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found