I once wrote something similar: https://github.com/albertz/py_better_exchook
Example: https://gist.github.com/albertz/922622
It does not dump all local vars though, only those which appear in the line where the exception happened. And not only local but also global. But also including subfields, like `obj.field`. And it does that in a kind of hacky way, via some embedded simple Python parsing, but it works most of the way just fine.