msg147196 - (view) |
Author: Florent Xicluna (flox) *  |
Date: 2011-11-06 23:46 |
>>> import logging >>> log = logging.getLogger(any) Traceback (most recent call last): File "", line 1, in File "./Lib/logging/__init__.py", line 1730, in getLogger return Logger.manager.getLogger(name) File "./Lib/logging/__init__.py", line 1114, in getLogger self._fixupParents(rv) File "./Lib/logging/__init__.py", line 1142, in _fixupParents i = name.rfind(".") AttributeError: 'builtin_function_or_method' object has no attribute 'rfind' >>> log = logging.getLogger(any) >>> log.error("It should not create this logger") It should not create this logger >>> |
|
|
msg147211 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2011-11-07 08:55 |
New changeset 8c719e106694 by Vinay Sajip in branch 'default': Merged fix for #13361 from 3.2. http://hg.python.org/cpython/rev/8c719e106694 |
|
|
msg147212 - (view) |
Author: Florent Xicluna (flox) *  |
Date: 2011-11-07 08:56 |
I've uploaded two proposals: - first with isinstance(name, str) - second which is more duck-friendly Personally, I like ducks. |
|
|
msg147213 - (view) |
Author: Florent Xicluna (flox) *  |
Date: 2011-11-07 09:00 |
btw, changeset a3ba905447ba does not fix the case for: import logging log = logging.Logger(any) |
|
|
msg147214 - (view) |
Author: Vinay Sajip (vinay.sajip) *  |
Date: 2011-11-07 09:12 |
@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. |
|
|
msg147216 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2011-11-07 10:16 |
New changeset 60dd1568bbd1 by Vinay Sajip in branch '2.7': Closes #13361: Raise correct exception type. http://hg.python.org/cpython/rev/60dd1568bbd1 New changeset bc05c11b340e by Vinay Sajip in branch '3.2': Closes #13361: Raise correct exception type. http://hg.python.org/cpython/rev/bc05c11b340e New changeset fb73fe5d0ab1 by Vinay Sajip in branch 'default': Closes #13361: Merge fix from 3.2. http://hg.python.org/cpython/rev/fb73fe5d0ab1 |
|
|
msg147254 - (view) |
Author: Eric Snow (eric.snow) *  |
Date: 2011-11-07 20:12 |
FYI, the following changesets were also for this issue. They had the wrong issue number (#13661, which doesn't actually exist so no big deal), which is why they didn't show up in this issue automatically. New changeset 5f3b7528b144 by Vinay Sajip in branch '2.7': Closes #13661: Check added for type of logger name. http://hg.python.org/cpython/rev/5f3b7528b144 New changeset a3ba905447ba by Vinay Sajip in branch '3.2': Closes #13661: Check added for type of logger name. http://hg.python.org/cpython/rev/a3ba905447ba |
|
|