One more way is 

```
if isinstance(formatter, LocalVarFormatter):
                    formatter.formatException(sys.exc_info())
```