[issue9317] Incorrect coverage file from trace test_pickle.py

Eli Bendersky report at bugs.python.org
Wed Jul 21 06:13:23 CEST 2010


Eli Bendersky <eliben at gmail.com> added the comment:

trace.py uses settrace to do its heavy lifting. In the "local trace" function for counting, localtrace_count:

    def localtrace_count(self, frame, why, arg):
        if why == "line":
            filename = frame.f_code.co_filename
            lineno = frame.f_lineno
            key = filename, lineno
            self.counts[key] = self.counts.get(key, 0) + 1
        return self.localtrace

The line "filename = frame.f_code.co_filename" seems to work as expected in 2.x for the current file, returning its name. In 3.x it returns '<string>' for the current file.

This causes the trace module to filter out the results for the current file (traceme.py in Alexander's example).

I'm investigating further, but this may very well be caused by different behavior of `f_code.co_filename` between Python 2 and 3.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9317>
_______________________________________


More information about the Python-bugs-list mailing list