Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(11)

Unified Diff: Lib/logging/config.py

Issue 15452: Improve the security model for logging listener()
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/ast.py ('k') | Lib/test/test_ast.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/logging/config.py Thu Oct 11 00:11:26 2012 -0700
+++ b/Lib/logging/config.py Thu Oct 11 16:47:49 2012 +0100
@@ -24,6 +24,7 @@
To use, simply 'import logging' and log away!
"""
+from ast import lookup_eval
import sys, logging, logging.handlers, socket, struct, traceback, re
import io
@@ -135,12 +136,14 @@
section = cp["handler_%s" % hand]
klass = section["class"]
fmt = section.get("formatter", "")
+ context = dict(vars(logging))
+ context['handlers'] = logging.handlers
try:
- klass = eval(klass, vars(logging))
- except (AttributeError, NameError):
+ klass = lookup_eval(klass, context, True)
+ except ValueError:
klass = _resolve(klass)
args = section["args"]
- args = eval(args, vars(logging))
+ args = lookup_eval(args, context, True)
h = klass(*args)
if "level" in section:
level = section["level"]
« no previous file with comments | « Lib/ast.py ('k') | Lib/test/test_ast.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+