[issue13361] getLogger does not check its argument

Vinay Sajip report at bugs.python.org
Mon Nov 7 10:12:08 CET 2011


Vinay Sajip <vinay_sajip at yahoo.co.uk> added the comment:

@Florent: Sorry, I didn't see your patch, for some reason. But I would say:

1. I agree that where I put the check (logging.getLogger) does not catch the case where someone instantiates the logger directly (using logging.Logger(any)), but users aren't supposed to instantiate loggers directly anyway - this would not result in a working logger. The check is in the same place where (in 2.7) we check for Unicode and encode to bytes.

2. I don't want to be too liberal in accepting logger names, since they are intended to mean "a place in the application". So, accepting anything other than text does not seem right to me - so str for 3.x, str or unicode for 2.x.

3. I thought a single test (passing in a invalid type) would be sufficient for the logging code, ISTM adding tests with lots of types is actually testing isinstance ;-)

4. I didn't notice your patch, and hence goofed in raising a ValueError instead of (correctly as you had it) a TypeError. I will rectify this.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13361>
_______________________________________


More information about the Python-bugs-list mailing list