Martin <[email protected]> added the comment:
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
----------
keywords: +patch
message_count: 3.0 -> 4.0
nosy: +moi90
nosy_count: 4.0 -> 5.0
pull_requests: +27572
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/29299
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue23597>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com