Skip to content
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

logging style parameter does not work correctly #64441

Closed
kespindler mannequin opened this issue Jan 13, 2014 · 5 comments
Closed

logging style parameter does not work correctly #64441

kespindler mannequin opened this issue Jan 13, 2014 · 5 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@kespindler
Copy link
Mannequin

kespindler mannequin commented Jan 13, 2014

BPO 20242
Nosy @vsajip
Files
  • Issue20242.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/vsajip'
    closed_at = <Date 2014-01-13.22:01:29.263>
    created_at = <Date 2014-01-13.18:41:50.516>
    labels = ['type-bug', 'library']
    title = 'logging style parameter does not work correctly'
    updated_at = <Date 2014-01-13.22:01:29.262>
    user = 'https://bugs.python.org/kespindler'

    bugs.python.org fields:

    activity = <Date 2014-01-13.22:01:29.262>
    actor = 'python-dev'
    assignee = 'vinay.sajip'
    closed = True
    closed_date = <Date 2014-01-13.22:01:29.263>
    closer = 'python-dev'
    components = ['Library (Lib)']
    creation = <Date 2014-01-13.18:41:50.516>
    creator = 'kespindler'
    dependencies = []
    files = ['33446']
    hgrepos = []
    issue_num = 20242
    keywords = ['patch']
    message_count = 5.0
    messages = ['208035', '208038', '208048', '208049', '208050']
    nosy_count = 3.0
    nosy_names = ['vinay.sajip', 'python-dev', 'kespindler']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue20242'
    versions = ['Python 3.3', 'Python 3.4']

    @kespindler
    Copy link
    Mannequin Author

    kespindler mannequin commented Jan 13, 2014

    In Python 3.3, 3.4beta2, and bleeding edge (88411:e7d922d8ee03), the following occurs

    >>> import logging
    >>> logging.basicConfig(style="{")
    >>> logging.error("hello")
    %(levelname)s:%(name)s:%(message)s

    Of course, I would expect

    ERROR:root:hello

    to be output instead.

    @kespindler kespindler mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jan 13, 2014
    @kespindler
    Copy link
    Mannequin Author

    kespindler mannequin commented Jan 13, 2014

    I created a patch that fixes this behavior for both { and $ style formats.

    Previously, default format strings were not being set correctly for those styles. This patch ensures that the correct default_format string is used.

    There is a minor "weirdness" issue that, due to there previously being 2 different default format strings for % style formatting, some tests rely on one, and some tests rely on the other. My patch remains backwards compatible with both default styles of format strings.

    This patch also includes test cases for behavior with the style keyword, which was not being tested before.

    @vsajip
    Copy link
    Member

    vsajip commented Jan 13, 2014

    Thanks for this. The patch looks good, and I expect to implement it shortly.

    @vsajip vsajip self-assigned this Jan 13, 2014
    @vsajip
    Copy link
    Member

    vsajip commented Jan 13, 2014

    On further reflection, I will implement this slightly differently. The tests I will commit as is, except for stripping newlines before the comparison (to avoid worrying about differences in line separators across different platforms). However, the correct fix IMO is to add the default format strings to the _STYLES dict values: the effect should be the same.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jan 13, 2014

    New changeset e7fcf0d8008f by Vinay Sajip in branch '3.3':
    Issue bpo-20242: Fixed basicConfig() format strings for the alternative formatting styles.
    http://hg.python.org/cpython/rev/e7fcf0d8008f

    New changeset c1605d24fb35 by Vinay Sajip in branch 'default':
    Closes bpo-20242: Merged fix from 3.3.
    http://hg.python.org/cpython/rev/c1605d24fb35

    @python-dev python-dev mannequin closed this as completed Jan 13, 2014
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant