Author kinow
Recipients kinow
Date 2019-07-22.04:30:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>

Tested on Python 3.7 on Ubuntu LTS. But I believe this affects previous versions too, as found it from an issue posted in Jinja2 in 2013:

This code simulates the issue where the traceback has the wrong line number (without using any Jinja2 code):

class Z(object):
    def __str__(self):
        raise ValueError('Z error')

def raise_generator():
    yield 'three values are: %s %s %s' % (
        Z(),  # traceback must point to this lineno 9
        'terceiro'  # but points to this lineno 10 (__str__ only, __eq__ is OK)


The output:

Traceback (most recent call last):
  File "/home/kinow/Development/python/workspace/cylc-flow/cylc/flow/tests/", line 14, in <module>
  File "/home/kinow/Development/python/workspace/cylc-flow/cylc/flow/tests/", line 10, in raise_generator
    'terceiro'  # but points to this lineno 10 (__str__ only, __eq__ is OK)
  File "/home/kinow/Development/python/workspace/cylc-flow/cylc/flow/tests/", line 3, in __str__
    raise ValueError('Z error')
ValueError: Z error

Jinja uses something similar to the class Z to raise errors when the template has undefined variables. The curious part is that if instead of simply formatting the string with "%s" % (Z()) you use "%s" % (str(Z())) or if you callZ().__str__(), then the traceback reports the correct line number.

Not sure if intentional, but would be nice if the traceback reported the correct line number, and I think other applications could end up having the same issue.

This is my first issue, so I apologize if I did not include enough information, or if there is anything missing in this ticket. Let me know if I need to update it with more information or formatting the code.

Would be happy to work on this if this is considered an easy-to-fix issue.

Thanks all for your work on Python,

Bruno P. Kinoshita
Date User Action Args
2019-07-22 04:30:20kinowsetrecipients: + kinow
2019-07-22 04:30:20kinowsetmessageid: <>
2019-07-22 04:30:20kinowlinkissue37647 messages
2019-07-22 04:30:19kinowcreate