Skip to content

bpo-40756: Default second argument of LoggerAdapter.__init__ to None #20362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2020

Conversation

arturoescaip
Copy link
Contributor

@arturoescaip arturoescaip commented May 24, 2020

The 'extra' argument is not always used by custom logger adapters. For
example:

class IndentAdapter(logging.LoggerAdapter):
    def process(self, msg, kwargs):
        indent = kwargs.pop(indent, 1)
        return ' ' * indent + msg, kwargs

It is cleaner and friendlier to default the 'extra' argument to None
instead of either forcing the subclasses of LoggerAdapter to pass a None
value directly or to override the constructor.

This change is backward compatible because existing calls to
LoggerAdapter.__init__ are already passing a value for the second
argument.

https://bugs.python.org/issue40756

Automerge-Triggered-By: @vsajip

The 'extra' argument is not always used by custom logger adapters. For
example:

class IndentAdapter(logging.LoggerAdapter):
    def process(self, msg, kwargs):
        indent = kwargs.pop(indent, 1)
        return ' ' * indent + msg, kwargs

It is cleaner and friendlier to default the 'extra' argument to None
instead of either forcing the subclasses of LoggerAdapter to pass a None
value directly or to override the constructor.

This change is backwards compatible because existing calls to
LoggerAdapter.__init__ are already passing a value for the second
argument.
@arturoescaip
Copy link
Contributor Author

@vsajip This is the new version of #20114 after botching that pull request 😞

It looks like the blurb tool required a bpo number, so I created one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants