Author HJarausch
Recipients Aaron.Meurer, HJarausch, inducer, r.david.murray
Date 2013-03-14.08:05:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1363248317.21.0.125695665067.issue17413@psf.upfronthosting.co.za>
In-reply-to
Content
The problem is caused by the new format_exception in Python's traceback.py file. It reads

def format_exception(etype, value, tb, limit=None, chain=True): 
  list = []
  if chain:
     values = _iter_chain(value, tb)
  else:
     values = [(value, tb)]
  for value, tb in values:
      if isinstance(value, str):

and then

def _iter_chain(exc, custom_tb=None, seen=None):
    if seen is None:
        seen = set()
    seen.add(exc)
    its = []
    context = exc.__context__

As you can see, the new keyword parameter chain is True by default. Thus, iter_chain is called by default.

And there you have context= exc.__context__.
Now, if value is an object of type str Python tries to access the __context__ field of an object of type str.

And this raises an attribute error.

In an application (pudb) I've used the fixed

exc_info= sys.exc_info()
....
format_exception(*exc_info,chain=not isinstance(exc_info[1],str))

So, why is the keyword parameter 'chain' True by default.
This causes the problem.
History
Date User Action Args
2013-03-14 08:05:17HJarauschsetrecipients: + HJarausch, inducer, r.david.murray, Aaron.Meurer
2013-03-14 08:05:17HJarauschsetmessageid: <1363248317.21.0.125695665067.issue17413@psf.upfronthosting.co.za>
2013-03-14 08:05:17HJarauschlinkissue17413 messages
2013-03-14 08:05:16HJarauschcreate