Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8506069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:29:43+00:00 2026-06-11T02:29:43+00:00

I’m appending an object to list images (initialized as empty) at every iteration of

  • 0

I’m appending an object to list images (initialized as empty) at every iteration of a for loop. I’m not explicitly accessing the list by index, I’m just appending an object to it, which is why to me inexplicable that I get an IndexError: list index out of range back.

Here’s the stack trace:

  Traceback (most recent call last):
   File "/mnt/www-data/run/backend/lib/python2.7/site-packages/flask/app.py", line 1504, in wsgi_app
     response = self.full_dispatch_request()
   File "/mnt/www-data/run/backend/lib/python2.7/site-packages/flask/app.py", line 1264, in full_dispatch_request
     rv = self.handle_user_exception(e)
   File "/mnt/www-data/run/backend/lib/python2.7/site-packages/flask/app.py", line 1262, in full_dispatch_request
     rv = self.dispatch_request()
   File "/mnt/www-data/run/backend/lib/python2.7/site-packages/flask/app.py", line 1248, in dispatch_request
     return self.view_functions[rule.endpoint](**req.view_args)
   File "/mnt/www-data/run/backend/lib/python2.7/site-packages/newrelic-1.4.0.137-py2.7-linux-x86_64.egg/newrelic/api/object_wrapper.py", line 166, in __call__
     self._nr_instance, args, kwargs)
   File "/mnt/www-data/run/backend/lib/python2.7/site-packages/newrelic-1.4.0.137-py2.7-linux-x86_64.egg/newrelic/api/function_trace.py", line 81, in literal_wrapper
     return wrapped(*args, **kwargs)
   File "/mnt/www-data/run/backend/lib/python2.7/site-packages/newrelic-1.4.0.137-py2.7-linux-x86_64.egg/newrelic/api/name_transaction.py", line 58, in __call__
     return self._nr_next_object(*args, **kwargs)
   File "/mnt/www-data/run/backend/webservice/decorators/controller_wrapper.py", line 75, in decorated_function
     return _return(f(*args, body=body, **kwargs))
   File "/mnt/www-data/run/backend/webservice/decorators/controller_wrapper.py", line 90, in decorated_function
     r = f(*args, **kwargs)
   File "/mnt/www-data/run/backend/webservice/decorators/login_required.py", line 16, in decorated_function
     return f(*args, **kwargs)
   File "/mnt/www-data/run/backend/webservice/controllers/me/photos.py", line 28, in create_photo
     phs = photos.store_photos(g.user, data)
   File "/mnt/www-data/run/backend/evertale/tasks/photos.py", line 106, in store_photos
     images.append(entity)
  IndexError: list index out of range

And an excerpt of …/tasks/photos.py, the failing line is the last of the for loop:

def store_photos(user, photos, update=False):
    if type(photos) is dict:
        photos = [photos]

    images = []
    for pic in photos:
        if 'gps' in pic and pic['gps']:
            loc = Location(ts=long(pic['ts']), user=user, _latlon=pic['gps'])
            loc.save()
        image = None
        if 'data' in pic:
            image = _read_image_from_base64(pic['data'])
            image = _normalize_rotation(image)
        entity = _persist_entity(user, image, update, **pic)
        if image:
            file_name = _file_name(entity.id)
            _persist_file(image, file_name)
            thumb_photo(entity.id)
        images.append(entity)

    if len(images) > 1:
        return images
    elif len(images) == 1:
        return images[0]
    else:
        return []

Anyone having any idea why this happens? I can’t debug this because the code is on the production server, and I’ve never experienced anything like it when testing on local machine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:29:44+00:00Added an answer on June 11, 2026 at 2:29 am

    I suspect the sourcecode on your server has changed since you started it. In fact, I am almost certain of it.

    Python byte-code includes a line number, and when a traceback occurs, this line number is used to look up and show you the non-compiled source line.

    Once the bytecode is loaded into memory however, it is not reloaded if you were to change the source file. If you add or remove lines from the source file after your server has started, lines in a traceback will be wrong.

    In other words, the line shown in your traceback is almost certainly not the line where the error occurs. I certainly would not expect a simple .append() to ever throw that exception. The specific exception (list index out of range) would only occur when trying to look up a specific entry in the list through __getattr__ (a lst[index] operation).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I need a function that will clean a strings' special characters. I do NOT
I am trying to loop through a bunch of documents I have to put
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.