On 2/19/17, Eric V. Smith <e...@trueblade.com> wrote:
> On 2/18/2017 2:25 AM, Steven D'Aprano wrote:

>> I see three problems:
>>
>> (1) It will be a bug magnet. People will accidently write
>>
>>     logging.debug('%03d %C03d', 1, expensive())
>>
>>
>> and then not only will their code still be slow, but they'll have to
>> debug mysterious
>>
>>     TypeError: 'int' object is not callable
>>
>> exceptions, but only *sometimes*. Most insideously, these Heisenbugs
>> will only occur when they turn the log level all the way up to
>> debugging, which will crash their program *before* logging the error!
>
> I think this is lessened with my proposal to use !c, but it's definitely
> still an issue. Test your logging!

1. I think that error message could be understandable at least as this:
    '{:g}'.format('a')
    ValueError: Unknown format code 'g' for object of type 'str'

with something like isinstance(arg, callable)

2. Static checker could check bracket presence if there is !c format
specifier and fire warning.

3. There could be another problem if return type is callable too...
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to