Reviewed: https://review.openstack.org/462735 Committed: https://git.openstack.org/cgit/openstack/oslo.log/commit/?id=72e5c3c1e258589957011506c36dd8af0a481513 Submitter: Jenkins Branch: master
commit 72e5c3c1e258589957011506c36dd8af0a481513 Author: melanie witt <[email protected]> Date: Thu May 4 20:22:47 2017 +0000 Use dict arg values for unicode checks in ContextFormatter In ContextFormatter.format(), for python2 it checks each arg to determine whether unicode should be used for the format message. The problem is the code assumes the args are a list, when they can also be a dict, for example: LOG.info('%(thing)s', {'thing': '...'}) and in that case, the dict keys were implicitly being used for the checks. The checks will always pass on string dict keys, so the format message gets converted to unicode even though the corresponding args will ultimately fail decoding to unicode. Then, the logging fails with: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc6 in position 0: ordinal not in range(128) when the unicode format message causes an implicit conversion attempt of the args to unicode [1]. This adds a check for the args type and uses the dict values for the unicode checks so that dict args with values that fail decoding will have: should_use_unicode = False. Closes-Bug: #1580728 [1] https://github.com/python/cpython/blob/2e576f5/Lib/logging/__init__.py#L338 Change-Id: I8c479e507efcf8acd3e3faa4a702fa6e1f18772f ** Changed in: oslo.log Status: In Progress => Fix Released -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to OpenStack Compute (nova). https://bugs.launchpad.net/bugs/1580728 Title: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 386: ordinal not in range(128) in nova.virt.libvirt.vif:unplug with unicode instance.display_name Status in devstack: Confirmed Status in OpenStack Compute (nova): Fix Released Status in oslo.log: Fix Released Status in oslo.versionedobjects: New Bug description: I saw this in the n-cpu logs for a xenproject CI run: http://logs.openstack.xenproject.org/00/315100/1/check/dsvm-tempest- xen/9649dc5/logs/screen-n-cpu.txt.gz 2016-05-11 16:19:09.457 27252 INFO nova.virt.libvirt.driver [-] [instance: 76c4ad96-87dd-4300-acdc-cbe65d3aa0a6] Instance destroyed successfully. Traceback (most recent call last): File "/usr/lib/python2.7/logging/__init__.py", line 851, in emit msg = self.format(record) File "/usr/local/lib/python2.7/dist-packages/oslo_log/handlers.py", line 73, in format return logging.StreamHandler.format(self, record) File "/usr/lib/python2.7/logging/__init__.py", line 724, in format return fmt.format(record) File "/usr/local/lib/python2.7/dist-packages/oslo_log/formatters.py", line 265, in format return logging.Formatter.format(self, record) File "/usr/lib/python2.7/logging/__init__.py", line 464, in format record.message = record.getMessage() File "/usr/lib/python2.7/logging/__init__.py", line 328, in getMessage msg = msg % self.args UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 386: ordinal not in range(128) Logged from file vif.py, line 966 That would be logging the vif object in unplug: https://github.com/openstack/nova/blob/15abb39ef20ae76d602d50e67e43c3500a00cd3e/nova/virt/libvirt/vif.py#L966 To manage notifications about this bug go to: https://bugs.launchpad.net/devstack/+bug/1580728/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : [email protected] Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp

