Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Doesn't work with Django's SimpleLazyObject #92
I'm using pycallgraph 0.5.1, Django 1.3.1, Python 2.7.2 32bit.
Line 235 of pycallgraph.py, which gets the "class" of "self" in the current call being traced, causes an infinite loop. The method being traced is SimpleLazyObject's "init", which among other things sets "self._wrapped". ".class" triggers the "__get_class" method on the object, which checks if "_wrapped" is None, but since the constructor hasn't run yet (it was intercepted by the tracer), this gets translated into a "getattr" call on the object, which again checks if "_wrapped" is None... etc.
Here is the relevant part the stack trace. I used custom middleware to integrate pycallgraph in Django.
C:\Python27\lib\site-packages\django\contrib\auth\context_processors.py in auth
Same issue on django 1.4.2
I'll make a pull request upstream once I get some time to write tests, explain this, etc.