New submission from Ned Batchelder <n...@nedbatchelder.com>:

When decorating a function, the sequence of lines reported to the trace 
function is different in Python3.8 than with previous versions

$ cat -n decorator.py
     1  def decorator(f):
     2      return f
     3
     4  def f():
     5      @decorator
     6      @decorator
     7      @decorator
     8      def func():
     9          pass
    10
    11  import sys
    12  def trace(frame, event, args):
    13      print(frame.f_lineno, event)
    14      return trace
    15
    16  sys.settrace(trace)
    17  f()

$ python3.7 decorator.py
4 call
5 line
6 line
7 line
1 call
2 line
2 return
1 call
2 line
2 return
1 call
2 line
2 return
7 return

$ python3.8 decorator.py
4 call
5 line
6 line
7 line
5 line
1 call
2 line
2 return
1 call
2 line
2 return
1 call
2 line
2 return
5 return

Is this intentional? Will it be changed back before 3.8 ships?

People are testing their projects against 3.8-dev, and reporting problems with 
coverage.  The problems are due to these sorts of changes.

----------
components: Interpreter Core
messages: 326921
nosy: nedbat
priority: normal
severity: normal
status: open
title: Python3.8 changes how decorators are traced
versions: Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34876>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to