This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2015年03月06日 02:12 by ncoghlan, last changed 2022年04月11日 14:58 by admin.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 29299 | moi90, 2021年10月29日 06:27 | ||
| Messages (4) | |||
|---|---|---|---|
| msg237319 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2015年03月06日 02:12 | |
Issue #22936 added support for easily displaying local variables in tracebacks to the unittest and traceback modules. Would it be worth also making this capability readily available in the logging APIs that display traceback messages? The main argument against it is that automatically logging local variables in tracebacks is a *really* good way to introduce sensitive information leaks into your log messages. "Safe repr" type objects (which automatically mask sensitive details in __repr__()) can mitigate this, but we don't provide such an object in the standard library (not even for bytes, bytearray or str, which are the typical containers for potentially sensitive data like passwords). |
|||
| msg237323 - (view) | Author: Robert Collins (rbcollins) * (Python committer) | Date: 2015年03月06日 02:27 | |
Yes, for debugging etc this can be very useful. I suggest further extending the new traceback interface to allow a filtering/transform hook of some sort, to allow folk more granular control than just repr overloading. |
|||
| msg404737 - (view) | Author: Irit Katriel (iritkatriel) * (Python committer) | Date: 2021年10月22日 09:42 | |
See also 43656. |
|||
| msg405287 - (view) | Author: Martin (moi90) * | Date: 2021年10月29日 06:27 | |
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
|
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:13 | admin | set | github: 67785 |
| 2021年10月29日 06:27:23 | moi90 | set | nosy:
+ moi90 messages: + msg405287 pull_requests: + pull_request27572 keywords: + patch stage: patch review |
| 2021年10月22日 09:42:19 | iritkatriel | set | nosy:
+ iritkatriel messages: + msg404737 |
| 2021年10月22日 09:41:33 | iritkatriel | set | type: enhancement versions: + Python 3.11, - Python 3.5 |
| 2015年08月26日 00:33:02 | cvrebert | set | nosy:
+ cvrebert |
| 2015年03月06日 02:27:44 | rbcollins | set | nosy:
+ rbcollins messages: + msg237323 |
| 2015年03月06日 02:13:00 | ncoghlan | set | dependencies: + traceback module has no way to show locals |
| 2015年03月06日 02:12:46 | ncoghlan | create | |