example usage.py LOG.exception("An Exception occurred") failed when use py34

Bug #1578071 reported by Haifeng.Yan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.log
Fix Released
Undecided
Haifeng.Yan

Bug Description

ubuntu 14.04
py34
solo.log master latest code

when I executed the examples code " doc/source/examples/usage.py ", it raise exception as follow:

(py34) evan@devstack:~/code/openstack/oslo.log$ python doc/source/examples/usage.py
2016-05-04 14:19:10.634 21809 INFO __main__ [-] Welcome to Oslo Logging
2016-05-04 14:19:10.634 21809 WARNING __main__ [-] A warning occurred
2016-05-04 14:19:10.635 21809 ERROR __main__ [-] An error occurred
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.4/logging/__init__.py", line 978, in emit
    msg = self.format(record)
  File "/home/evan/code/openstack/oslo.log/oslo_log/handlers.py", line 73, in format
    return logging.StreamHandler.format(self, record)
  File "/usr/lib/python3.4/logging/__init__.py", line 828, in format
    return fmt.format(record)
  File "/home/evan/code/openstack/oslo.log/oslo_log/formatters.py", line 264, in format
    record.exc_text = self.formatException(record.exc_info, record)
  File "/home/evan/code/openstack/oslo.log/oslo_log/formatters.py", line 274, in formatException
    None, stringbuffer)
  File "/usr/lib/python3.4/traceback.py", line 169, in print_exception
    for line in _format_exception_iter(etype, value, tb, limit, chain):
  File "/usr/lib/python3.4/traceback.py", line 146, in _format_exception_iter
    for value, tb in values:
  File "/usr/lib/python3.4/traceback.py", line 125, in _iter_chain
    context = exc.__context__
AttributeError: 'NoneType' object has no attribute '__context__'
Call stack:
  File "doc/source/examples/usage.py", line 83, in <module>
    LOG.exception("An Exception occurred")
Message: 'An Exception occurred'
Arguments: ()

when use py27, it is fine:

(py27) evan@devstack:~/code/openstack/oslo.log$ python doc/source/examples/usage.py
2016-05-04 14:21:45.340 22128 INFO __main__ [-] Welcome to Oslo Logging
2016-05-04 14:21:45.340 22128 WARNING __main__ [-] A warning occurred
2016-05-04 14:21:45.341 22128 ERROR __main__ [-] An error occurred
2016-05-04 14:21:45.341 22128 ERROR __main__ [-] An Exception occurred
2016-05-04 14:21:45.341 22128 ERROR __main__ None
2016-05-04 14:21:45.341 22128 ERROR __main__

Haifeng.Yan (yanheven)
summary: - LOG.exception("An Exception occurred") failed
+ LOG.exception("An Exception occurred") failed when use py34
Revision history for this message
Haifeng.Yan (yanheven) wrote : Re: LOG.exception("An Exception occurred") failed when use py34
Download full text (3.5 KiB)

same issue appeared for usage_helper.py when use py34.

(py34) evan@devstack:~/code/openstack/oslo.log$ python doc/source/examples/usage_helper.py
DEBUG:__main__:Prepare Oslo Logging
INFO:__main__:Size of configuration options before 0
INFO:__main__:Size of configuration options after 19
INFO:__main__:List of Oslo Logging configuration options and current values
INFO:__main__:================================================================================
INFO:__main__:logging_debug_format_suffix = %(funcName)s %(pathname)s:%(lineno)d
INFO:__main__:log_file = None
INFO:__main__:use_syslog = False
INFO:__main__:logging_default_format_string = %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s
INFO:__main__:debug = False
INFO:__main__:log_config_append = None
INFO:__main__:logging_exception_prefix = %(asctime)s.%(msecs)03d %(process)d ERROR %(name)s %(instance)s
INFO:__main__:log_dir = None
INFO:__main__:default_log_levels = ['amqp=WARN', 'amqplib=WARN', 'boto=WARN', 'qpid=WARN', 'sqlalchemy=WARN', 'suds=INFO', 'oslo.messaging=INFO', 'iso8601=WARN', 'requests.packages.urllib3.connectionpool=WARN', 'urllib3.connectionpool=WARN', 'websocket=WARN', 'requests.packages.urllib3.util.retry=WARN', 'urllib3.util.retry=WARN', 'keystonemiddleware=WARN', 'routes.middleware=WARN', 'stevedore=WARN', 'taskflow=WARN', 'keystoneauth=WARN', 'oslo.cache=INFO', 'dogpile.core.dogpile=INFO', 'dogpile=INFO', 'routes=INFO']
INFO:__main__:syslog_log_facility = LOG_USER
INFO:__main__:instance_format = [instance: %(uuid)s]
INFO:__main__:logging_user_identity_format = %(user)s %(tenant)s %(domain)s %(user_domain)s %(project_domain)s
INFO:__main__:publish_errors = False
INFO:__main__:use_stderr = True
INFO:__main__:verbose = True
INFO:__main__:log_date_format = %Y-%m-%d %H:%M:%S
INFO:__main__:watch_log_file = False
INFO:__main__:logging_context_format_string = %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s
INFO:__main__:instance_uuid_format = [instance: %(uuid)s]
INFO:__main__:================================================================================
2016-05-04 15:32:29.510 30676 INFO __main__ [-] Welcome to Oslo Logging
2016-05-04 15:32:29.511 30676 WARNING __main__ [-] A warning occurred
2016-05-04 15:32:29.511 30676 ERROR __main__ [-] An error occurred
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.4/logging/__init__.py", line 978, in emit
    msg = self.format(record)
  File "/home/evan/code/openstack/oslo.log/oslo_log/handlers.py", line 73, in format
    return logging.StreamHandler.format(self, record)
  File "/usr/lib/python3.4/logging/__init__.py", line 828, in format
    return fmt.format(record)
  File "/home/evan/code/openstack/oslo.log/oslo_log/formatters.py", line 264, in format
    record.exc_text = self.formatException(record.exc_info, record)
  File "/home/evan/code/openstack/oslo.log/oslo_log/formatters.py", line 274, in formatException
    None, stringbuffer)
  File "/usr/lib/python3.4/traceback.py", line 169, in print_exception
    for line in _format_exception_iter(etype, value, tb, limit, chain):
  File...

Read more...

summary: - LOG.exception("An Exception occurred") failed when use py34
+ example usage.py LOG.exception("An Exception occurred") failed when use
+ py34
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo.log (master)

Fix proposed to branch: master
Review: https://review.openstack.org/312351

Changed in oslo.log:
assignee: nobody → Haifeng.Yan (yanheven)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.log (master)

Reviewed: https://review.openstack.org/312351
Committed: https://git.openstack.org/cgit/openstack/oslo.log/commit/?id=c63991fb4d0f02c27a10cc93b08a0d3901026755
Submitter: Jenkins
Branch: master

commit c63991fb4d0f02c27a10cc93b08a0d3901026755
Author: yan.haifeng <email address hidden>
Date: Wed May 4 15:38:42 2016 +0800

    Fix example issue

    example LOG.exception("An Exception occurred") in both usage.py,
    usage_helper.py and usage_i18n.py failed when use py34.

    fix it by raising exception before calling LOG.exception().

    Change-Id: I2b6ea35fbf171232fea0cc54265f8be3dc61457f
    Closes-Bug: #1578071

Changed in oslo.log:
status: In Progress → Fix Released
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/oslo.log 3.7.0

This issue was fixed in the openstack/oslo.log 3.7.0 release.

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.