dcramer/raven — Issue #72: Raven's stack iteration trashes exception frames
Author: mitsuhiko
Created: 2012-02-28 12:36:19+00:00
State: open

Currently the `get_stack_info` function assumes that frame.f_lineno is reliable. This however is not the case when the error cause and the error handler both life in the same frame. Unfortunately this is not changeable without changing the `get_stack_info` function.

Testcase:

```python
from raven.handlers.logging import SentryHandler
dsn = 'http://:@localhost:9000/1'
handler = SentryHandler(dsn)
from logging import getLogger
logger = getLogger()
logger.addHandler(handler)
try:
1/0
except:
logger.error('moep', exc_info=True)
```

The problem is that `frame.f_lineno` will be the line with the `logger.error` call but `traceback.tb_lineno` will point to the proper location of the traceback which is the `1/0` line. The workaround is to never log in the same frame as the one that caused the exception though that might not be a 100% fix.