Monday, May 30, 2011

Re: SystemError from django.conf.settings

On Sat, May 28, 2011 at 10:50 PM, Cameron <cameron@sandboxsoftware.net> wrote:
So I have this stack trace on my production server. I can't reproduce
it locally and it doesn't occur with an older version of the same site
deployed on the same server.

Traceback (most recent call last):
 File "./dependencies/django/core/handlers/wsgi.py", line 222, in
__call__
   from django.conf import settings
SystemError: ../Objects/tupleobject.c:118: bad argument to internal
function
 
1. Anyone seen this before? The only other reference that I can find
to that line of python is here (http://bugs.debian.org/cgi-bin/
bugreport.cgi?bug=581626)

I've never seen this before. Looking at the Python source (you mentioned that you're running 2.5.2 from Debian lenny,) this looks to me like it has to be an error in a C module somewhere -- probably a third-party module, but it's possible it's in the Python core somewhere.

The line itself is a sanity check in PyTuple_SetItem, which shouldn't even be available to Python code (tuples are supposed to be immutable, right?) It would only get triggered if it got called somehow with an argument that wasn't actually a tuple, or with a tuple for which another reference existed somewhere (besides in the initializing code).
 

2. Any tips on how I can find out what has changed to cause it? Aside
from rolling back through weeks of revisions to find what triggered
it.

If it's happening on settings import, then try importing settings manually from a python shell. You may see more of a stacktrace that way. If you still get the error, but can't pinpoint the failing line, then try running it through the debugger, and step from line to line until you see it. If you're lucky, there will be call to a function in an external module that triggers it, and you'll be able to narrow the possibilities down to that one module.

Failing that, a binary search through weeks or even months of revisions should only take O(lg n) time -- a small consolation, but searching weeks of development is only a couple of iterations more than searching a few days.


3. I am about to try upgrading python to a newer version, is that
likely to make any difference? I have already tried 2 different
versions of uwsgi (0.9.6.8 and 0.9.7.2), but I don't want to mess
around with the production environment too much, or risk breaking the
live sites.

If the error is in one of the python core modules, then it may have been fixed recently; but I haven't seen any reports of failures in tupleobject.c other than the Trac bug that you turned up. See if there are any other compiled modules in the system that you can update first.


--
Regards,
Ian Clelland
<clelland@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment