Message405287
In this pull request[1] I introduced a `format_locals` which can be provided to customize the serialization of the local variables of each frame. This could be used to filter out variables with certain names, for example. In this context, you could use a certain naming convention for variables with sensitive information and filter them out:
def _format_locals(filename, lineno, name, locals):
return {k: repr(v) for k,v in locals.items() if not k.endsswith("_sensitive")}
traceback.TracebackException.from_exception(e, capture_locals=True, format_locals=format_locals).format()
(This should be exactly what Robert was suggesting.)
[1] https://github.com/python/cpython/pull/29299 |
|
Date |
User |
Action |
Args |
2021-10-29 06:27:23 | moi90 | set | recipients:
+ moi90, ncoghlan, rbcollins, cvrebert, iritkatriel |
2021-10-29 06:27:23 | moi90 | set | messageid: <1635488843.48.0.08043499532.issue23597@roundup.psfhosted.org> |
2021-10-29 06:27:23 | moi90 | link | issue23597 messages |
2021-10-29 06:27:23 | moi90 | create | |
|