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: Logging formatter validation breaks backward ducktyping
Type: behavior Stage: resolved
Components: Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: BNMetrics, P.C. Kroon, vinay.sajip
Priority: normal Keywords:

Created on 2018-10-16 14:56 by P.C. Kroon, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg327837 - (view) Author: P.C. Kroon (P.C. Kroon) Date: 2018-10-16 14:56
Hi all!

This concerns commit 18fb1fb943b7dbd7f8a76017ee2a67ef13effb85 (also known as bpo-34844 or GH-9703).

For testing purposes I made something that transparently ducktypes being a string, except that it counts how often its `format` and `__mod__` methods are called. The validation mechanic now tries to pass my object to `self.validation_pattern.search` (line 441), which (of course) doesn't work. Due to backwards compatability I can't pass a validate keyword.
To resolve this, I'd like the default `validate` option to be set to `False` instead of `True`.

If the judgement is that I'm doing really weird things and should make an actual string subclass I'll also accept that and/or find an alternative solution.

Cheers, Peter
msg327851 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2018-10-17 01:54
Unfortunately, setting the default value of validate to False would completely negate the usefulness of the feature, because it would rely on people coming to know about it and remembering to turn it on. Given that this feature is adding error checking, and that

Errors should never pass silently.
Unless explicitly silenced.

I think that the default should remain as it is. I suggest that you either subclass str for your needs, or work around the backward compatibility issue by checking the version of Python you're running under.
msg327874 - (view) Author: P.C. Kroon (P.C. Kroon) Date: 2018-10-17 08:46
Hi Vinay,

thanks for the feedback. I agree with your arguments and find an alternative solution.

Peter
History
Date User Action Args
2022-04-11 14:59:07adminsetgithub: 79179
2018-10-17 08:46:25P.C. Kroonsetmessages: + msg327874
2018-10-17 01:54:58vinay.sajipsetstatus: open -> closed

nosy: + vinay.sajip, BNMetrics
messages: + msg327851

resolution: not a bug
stage: resolved
2018-10-16 14:56:59P.C. Krooncreate