LOG.exception fails on Python 2.x when the exception content needs decoding

Bug #1393870 reported by Alessandro Pilotti
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloudbase-init
Fix Released
Medium
Alessandro Pilotti
oslo-incubator
Won't Fix
Medium
Alessandro Pilotti

Bug Description

The following example, generates an exception in openstack.common.module:

http://paste.ubuntu.com/8574082/

    from openstack.common import log as logging

    with open("unicode-content.txt", 'rb') as f:
        text = f.read()
    LOG = logging.getLogger(__name__)
    LOG.exception(Exception(text))

The calling code should be responsible for decoding the content before assigning it as the exception message, but nevertheless, the logging module should handle this gracefully and not raise an exception.

Related bug: https://bugs.launchpad.net/cloudbase-init/+bug/1382047

affects: pbr → oslo-incubator
Revision history for this message
Alessandro Pilotti (alexpilotti) wrote :
Changed in cloudbase-init:
importance: Undecided → Medium
status: New → Triaged
Changed in oslo-incubator:
status: New → In Progress
Changed in cloudbase-init:
assignee: nobody → Alessandro Pilotti (alexpilotti)
Changed in oslo-incubator:
assignee: nobody → Alessandro Pilotti (alexpilotti)
Changed in cloudbase-init:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cloudbase-init (master)

Reviewed: https://review.openstack.org/135370
Committed: https://git.openstack.org/cgit/stackforge/cloudbase-init/commit/?id=5344904f27e19668681bf4623dc88a68f7b9bfca
Submitter: Jenkins
Branch: master

commit 5344904f27e19668681bf4623dc88a68f7b9bfca
Author: Alessandro Pilotti <email address hidden>
Date: Tue Nov 18 19:25:16 2014 +0200

    Fixes unicode logging decoding issue

    Logging fails with an exception when unicode conversion of the message
    cannot be performed.

    This includes also Exception objects, where the exception message has
    an unknown encoding.

    The calling code should be responsible for handling the unicode encoding, but
    nevertheless, the logging module should handle this scenario and not raise
    an exception.

    Closes-Bug: #1393870

    Change-Id: Ied46e4a8715d11a3cf59d651004e17f6fe4c760b

Changed in cloudbase-init:
status: In Progress → Fix Committed
Changed in cloudbase-init:
status: Fix Committed → Fix Released
Ben Nemec (bnemec)
Changed in oslo-incubator:
importance: Undecided → Medium
Changed in oslo-incubator:
status: In Progress → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.