Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
d4fabf41
Commit
d4fabf41
authored
Jul 13, 2009
by
Vinay Sajip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #6314: logging: Extra checks on the "level" argument.
parent
f67367e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
17 deletions
+23
-17
Lib/logging/__init__.py
Lib/logging/__init__.py
+15
-8
Misc/NEWS
Misc/NEWS
+8
-9
No files found.
Lib/logging/__init__.py
View file @
d4fabf41
...
...
@@ -176,6 +176,17 @@ def addLevelName(level, levelName):
finally
:
_releaseLock
()
def
_checkLevel
(
level
):
if
isinstance
(
level
,
int
):
rv
=
level
elif
str
(
level
)
==
level
:
if
level
not
in
_levelNames
:
raise
ValueError
(
"Unknown level: %r"
%
level
)
rv
=
_levelNames
[
level
]
else
:
raise
TypeError
(
"Level not an integer or a valid string: %r"
%
level
)
return
rv
#---------------------------------------------------------------------------
# Thread-related stuff
#---------------------------------------------------------------------------
...
...
@@ -593,7 +604,7 @@ class Handler(Filterer):
and the filter list to empty.
"""
Filterer
.
__init__
(
self
)
self
.
level
=
level
self
.
level
=
_checkLevel
(
level
)
self
.
formatter
=
None
#get the module data lock, as we're updating a shared structure.
_acquireLock
()
...
...
@@ -631,7 +642,7 @@ class Handler(Filterer):
"""
Set the logging level of this handler.
"""
self
.
level
=
level
self
.
level
=
_checkLevel
(
level
)
def
format
(
self
,
record
):
"""
...
...
@@ -1009,7 +1020,7 @@ class Logger(Filterer):
"""
Filterer
.
__init__
(
self
)
self
.
name
=
name
self
.
level
=
level
self
.
level
=
_checkLevel
(
level
)
self
.
parent
=
None
self
.
propagate
=
1
self
.
handlers
=
[]
...
...
@@ -1019,7 +1030,7 @@ class Logger(Filterer):
"""
Set the logging level of this logger.
"""
self
.
level
=
level
self
.
level
=
_checkLevel
(
level
)
def
debug
(
self
,
msg
,
*
args
,
**
kwargs
):
"""
...
...
@@ -1396,10 +1407,6 @@ def basicConfig(**kwargs):
root
.
addHandler
(
hdlr
)
level
=
kwargs
.
get
(
"level"
)
if
level
is
not
None
:
if
str
(
level
)
==
level
:
# If a string was passed, do more checks
if
level
not
in
_levelNames
:
raise
ValueError
(
"Unknown level: %r"
%
level
)
level
=
_levelNames
[
level
]
root
.
setLevel
(
level
)
#---------------------------------------------------------------------------
...
...
Misc/NEWS
View file @
d4fabf41
...
...
@@ -90,8 +90,7 @@ Core and Builtins
Library
-------
- Issue #6314: logging.basicConfig() performs extra checks on the "level"
argument.
- Issue #6314: logging: performs extra checks on the "level" argument.
- Issue #6274: Fixed possible file descriptors leak in subprocess.py
...
...
@@ -133,7 +132,7 @@ Library
-------
- Issue #6438: Fixed distutils.cygwinccompiler.get_versions : the regular
expression string pattern was trying to match against a bytes returned by
expression string pattern was trying to match against a bytes returned by
Popen. Tested under win32 to build the py-postgresql project.
- Issue #6258: Support AMD64 in bdist_msi.
...
...
@@ -892,22 +891,22 @@ Core and Builtins
Library
-------
- Issue #6459: distutils.command.build_ext.get_export_symbols now uses the
"PyInit" prefix, rather than "init".
- Issue #6459: distutils.command.build_ext.get_export_symbols now uses the
"PyInit" prefix, rather than "init".
- Issue #6455: Fixed test_build_ext under win32.
- Issue #6455: Fixed test_build_ext under win32.
- Issue #6377: Enabled the compiler option, and deprecate its usage as an
- Issue #6377: Enabled the compiler option, and deprecate its usage as an
attribute.
- Issue #6413: Fixed the log level in distutils.dist for announce.
- Issue #6403: Fixed package path usage in build_ext.
- Issue #6365: Distutils build_ext inplace mode was copying the compiled
- Issue #6365: Distutils build_ext inplace mode was copying the compiled
extension in a subdirectory if the extension name had dots.
- Issue #6164: Added an AIX specific linker argument in Distutils
- Issue #6164: Added an AIX specific linker argument in Distutils
unixcompiler. Original patch by Sridhar Ratnakumar.
- Issue #6286: Now Distutils upload command is based on urllib2 instead of
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment