[issue25474] Weird behavior when setting f_trace in a context manager

2015-11-02 Thread Fred Gansevles
Fred Gansevles added the comment: Xavier, thanks! you found it. If I look the code again, I see that with zero, one, four and five the context-manager (i.e. Context()) and the target (one .. five) are on the same code-line In the case of two and three they are on a different line. Now, with the

[issue25474] Weird behavior when setting f_trace in a context manager

2015-11-02 Thread Xavier de Gaye
Xavier de Gaye added the comment: The difference lies in the line numbers. When tracing lines, the interpreter operates on the basis of physical lines, not logical lines (https://docs.python.org/3/reference/lexical_analysis.html#line-structure). The local trace function is called on the

[issue25474] Weird behavior when setting f_trace in a context manager

2015-11-02 Thread Fred Gansevles
Fred Gansevles added the comment: Xavier, thanks for looking at my post. But, since all six invocations of the context manager are the same - I did an 'ast.parse' and 'ast.dump' and the the six calls were *exactly* the same (save lineno and col_offset) - why does 'zero', 'one', 'four' and

[issue25474] Weird behavior when setting f_trace in a context manager

2015-11-02 Thread Terry J. Reedy
Terry J. Reedy added the comment: Thank you Xavier. I guess the lesson is that physical line tracing works best (and most as one would hope or expect) when physical lines are logical lines (or compound statement header lines). -- resolution: -> not a bug stage: test needed ->

[issue25474] Weird behavior when setting f_trace in a context manager

2015-11-01 Thread Xavier de Gaye
Xavier de Gaye added the comment: This is an artefact that occurs as the result of raising an exception in the local trace function. Disassembling the first case of failure of as_context.py with the attached script gives the following: 9 0 LOAD_GLOBAL 0 (context)

[issue25474] Weird behavior when setting f_trace in a context manager

2015-10-30 Thread Terry J. Reedy
Terry J. Reedy added the comment: ZERO <__main__.Context object at 0x00874AF3E0B8> ONE <__main__.Context object at 0x00874AF326D8> Traceback (most recent call last): File "F:\Python\mypy\tem.py", line 45, in print ('TWO', two) NameError: name 'two' is not defined Traceback (most

[issue25474] Weird behavior when setting f_trace in a context manager

2015-10-25 Thread Fred Gansevles
New submission from Fred Gansevles: I'm playing with the idea of making a DSL based on anonynous code blocks I discovered that the behaviour of the context manager is different in some cases if there are line-continuations in the 'with' command I've attached a script that reproduces this