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 module fails with non-ascii data #48022

Closed
mhammond opened this issue Sep 4, 2008 · 2 comments
Closed

logging module fails with non-ascii data #48022

mhammond opened this issue Sep 4, 2008 · 2 comments
Assignees
Labels
release-blocker stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@mhammond
Copy link
Contributor

mhammond commented Sep 4, 2008

BPO 3772
Nosy @mhammond, @vsajip
Files
  • logging_encoding.patch: A test case and fix.
  • 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 2008-09-04.07:32:13.373>
    created_at = <Date 2008-09-04.03:47:14.630>
    labels = ['type-bug', 'library', 'release-blocker']
    title = 'logging module fails with non-ascii data'
    updated_at = <Date 2008-09-04.07:32:13.372>
    user = 'https://github.com/mhammond'

    bugs.python.org fields:

    activity = <Date 2008-09-04.07:32:13.372>
    actor = 'vinay.sajip'
    assignee = 'vinay.sajip'
    closed = True
    closed_date = <Date 2008-09-04.07:32:13.373>
    closer = 'vinay.sajip'
    components = ['Library (Lib)']
    creation = <Date 2008-09-04.03:47:14.630>
    creator = 'mhammond'
    dependencies = []
    files = ['11370']
    hgrepos = []
    issue_num = 3772
    keywords = ['patch']
    message_count = 2.0
    messages = ['72478', '72486']
    nosy_count = 2.0
    nosy_names = ['mhammond', 'vinay.sajip']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue3772'
    versions = ['Python 2.6']

    @mhammond
    Copy link
    Contributor Author

    mhammond commented Sep 4, 2008

    It appears r66103 introduced a regression - file objects are treated as
    having an encoding, so non-ascii data fails. It was further complicated
    by the fact that file objects in 2.6 have an 'encoding' attribute, but
    by default it is None - so a 'hasattr' check for encoding doesn't work
    the same.

    The fix is quite trivial and I also added a new test to demonstrate the
    error - but for the impatient, you can reproduce it via:

    import logging
    log = logging.getLogger("test")
    log.addHandler(logging.FileHandler("log.out"))
    log.warning("foo\x80")

    In all earlier versions of Python, the bytes as specified are written.
    2.6 complains that 'None' is not a valid encoding and fails to write the
    record.

    @mhammond mhammond added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 4, 2008
    @vsajip
    Copy link
    Member

    vsajip commented Sep 4, 2008

    Changes checked into trunk.

    @vsajip vsajip closed this as completed Sep 4, 2008
    @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
    release-blocker stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants