homepage

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.

classification
Title: _loggerClass is initialized twice
Type: Stage: resolved
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: python-dev, serhiy.storchaka, vinay.sajip
Priority: normal Keywords:

Created on 2015年01月02日 16:04 by serhiy.storchaka, last changed 2022年04月11日 14:58 by admin. This issue is now closed.

Messages (5)
msg233313 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015年01月02日 16:04
In Lib/logging/__init__.py at line 1089 _loggerClass is initialized to None. The code in Manager.getLogger() expects that it can be None. But at line 1549 _loggerClass is initialized to Logger. And there is no official way to set it to None. Looks as either initialization to None and the code in Manager.getLogger() are redundant or initialization to Logger is redundant.
msg233315 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2015年01月02日 16:46
The code in Manager.getLogger() allows an overriding logger class for that manager instance only - if it's not set (which is the default), it uses the module global _loggerClass. The lines
rv = (self.loggerClass or _loggerClass)(name)
indicate this.
The module global _loggerClass is initialized to None initially, simply so that it can be defined before being used in Manager (so really, for readability). Later, after Logger is defined, _loggerClass is set to Logger.
Is this causing some actual problem?
msg233317 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015年01月02日 18:02
> Is this causing some actual problem?
No, this does not cause actual problem except that it looks confusing. So really this decreased readability to me.
msg233321 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2015年01月02日 18:59
Okay, I'll see if I can make it clearer.
msg233515 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015年01月06日 10:56
New changeset 8bfe230db0bc by Vinay Sajip in branch 'default':
Closes #23151: Removed unnecessary initialization.
https://hg.python.org/cpython/rev/8bfe230db0bc 
History
Date User Action Args
2022年04月11日 14:58:11adminsetgithub: 67340
2015年01月06日 10:56:23python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg233515

resolution: fixed
stage: resolved
2015年01月02日 18:59:26vinay.sajipsetmessages: + msg233321
2015年01月02日 18:02:49serhiy.storchakasetmessages: + msg233317
2015年01月02日 16:46:06vinay.sajipsetmessages: + msg233315
2015年01月02日 16:04:33serhiy.storchakacreate

AltStyle によって変換されたページ (->オリジナル) /