Skip to content

logging don't encode Unicode message correctly. #50018

Closed

Description

@methane
BPO 5768
Nosy @vsajip, @amauryfa, @methane
Files
  • logging_init.diff: logging/init.py
  • logging_encoding.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 2009-04-16.19:17:39.119>
    created_at = <Date 2009-04-16.06:46:24.090>
    labels = ['type-bug', 'library']
    title = "logging don't encode Unicode message correctly."
    updated_at = <Date 2009-04-16.19:17:39.117>
    user = 'https://github.com/methane'

    bugs.python.org fields:

    activity = <Date 2009-04-16.19:17:39.117>
    actor = 'vinay.sajip'
    assignee = 'vinay.sajip'
    closed = True
    closed_date = <Date 2009-04-16.19:17:39.119>
    closer = 'vinay.sajip'
    components = ['Library (Lib)']
    creation = <Date 2009-04-16.06:46:24.090>
    creator = 'methane'
    dependencies = []
    files = ['13698', '13705']
    hgrepos = []
    issue_num = 5768
    keywords = ['patch']
    message_count = 3.0
    messages = ['86015', '86025', '86039']
    nosy_count = 3.0
    nosy_names = ['vinay.sajip', 'amaury.forgeotdarc', 'methane']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue5768'
    versions = ['Python 2.6']

    Activity

    1. methane commented on Apr 16, 2009

      @methane
      MemberAuthor
      >>> logging.error(u'あ')
      ERROR:root:縺・
      >>> sys.stderr.encoding
      'cp932'

      This bug is introduced by following commit.
      http://svn.python.org/view/python/branches/release26-
      maint/Lib/logging/init.py?r1=68830&r2=69448

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on Apr 16, 2009
    3. amauryfa commented on Apr 16, 2009

      @amauryfa
      Contributor

      I think that in r69448, the test does not match the code:
      codecs.getwriter('cp1251') has no attribute 'encoding', and no function
      in test_logging ever pass a stream with an explicit encoding.

      Also, the test in emit() should be reversed, otherwise msg.encode() is
      called only when msg is a 8bit string. And in this case, a unicode
      string should be passed to the stream.

      See attached patch.
      The codecs.getwriter should probably grow an 'encoding' attribute
      automatically, but this is another issue.

    4. vsajip commented on Apr 16, 2009

      @vsajip
      Member

      Fix checked into trunk and release26-maint.

    5. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions