This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: trace module bug when using --missing
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.1, Python 3.2
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: amaury.forgeotdarc Nosy List: amaury.forgeotdarc, eli.bendersky, georg.brandl, jjdominguezm, r.david.murray
Priority: low Keywords: needs review, patch

Created on 2008-09-09 16:07 by jjdominguezm, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
trace.patch amaury.forgeotdarc, 2008-09-11 00:06
Messages (6)
msg72879 - (view) Author: Juan Javier (jjdominguezm) Date: 2008-09-09 16:07
I get the following exception:

$ /opt/python3.0b2/bin/python3.0 -m trace -c -m
Traceback (most recent call last):
  File "/opt/python3.0b2/lib/python3.0/", line 121, in
    "__main__", fname, loader, pkg_name)
  File "/opt/python3.0b2/lib/python3.0/", line 34, in _run_code
    exec(code, run_globals)
  File "/opt/python3.0b2/lib/python3.0/", line 809, in <module>
  File "/opt/python3.0b2/lib/python3.0/", line 806, in main
    results.write_results(missing, summary=summary, coverdir=coverdir)
  File "/opt/python3.0b2/lib/python3.0/", line 303, in write_results
    lnotab = find_executable_linenos(filename)
  File "/opt/python3.0b2/lib/python3.0/", line 428, in
    return find_lines(code, strs)
  File "/opt/python3.0b2/lib/python3.0/", line 392, in find_lines
    linenos.update(find_lines(c, strs))
  File "/opt/python3.0b2/lib/python3.0/", line 386, in find_lines
    linenos = find_lines_from_code(code, strs)
  File "/opt/python3.0b2/lib/python3.0/", line 370, in
    line_increments = [ord(c) for c in code.co_lnotab[1::2]]
  File "/opt/python3.0b2/lib/python3.0/", line 370, in <listcomp>
    line_increments = [ord(c) for c in code.co_lnotab[1::2]]
TypeError: ord() expected string of length 1, but int found

I think that line 370 of should say:

line_increments = [int(c) for c in code.co_lnotab[1::2]]

instead of:

line_increments = [ord(c) for c in code.co_lnotab[1::2]]
msg72951 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-09-10 09:36
This can be further simplified:
   line_increments = code.co_lnotab[1::2]

Assigning to myself, I will try to add unit tests as well. the trace
module is not tested at all...
msg72998 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-09-11 00:06
Here is a simple test suite for the trace module, and two corrections to 
make it work.

The test file is suitable for 2.6 (simply replace with 
msg88541 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-05-29 21:46
Brett Cannon apparently fixed this in r69111 for 3.1.  I merged it to
the 30-maint branch in r73030.

It would be nice to add the tests, but they don't currently pass
(test_coverage_ignore fails).  I don't know if that's a test bug or a
code bug, not being familiar with the trace module.
msg112458 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-08-02 12:49
Fixed the test cases and committed them in r83527.
msg113076 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2010-08-06 06:04
TestCoverage.test_coverage_ignore fails when running in verbose mode ("python -v test_trace", or directly "python"), because it attempts to compare stdout.getvalue() with the empty string, while verbose places output there.

I will fix it as part of my merge with the larger for issue 9315.
Date User Action Args
2022-04-11 14:56:38adminsetgithub: 48071
2011-01-08 22:17:05terry.reedysetnosy: georg.brandl, amaury.forgeotdarc, jjdominguezm, r.david.murray, eli.bendersky
versions: + Python 3.2, - Python 3.0
2010-08-06 06:04:57eli.benderskysetnosy: + eli.bendersky
messages: + msg113076
2010-08-02 12:49:04georg.brandlsetstatus: open -> closed
nosy: + georg.brandl
messages: + msg112458

2009-05-29 21:46:05r.david.murraysetpriority: critical -> low

type: behavior
versions: + Python 3.1
nosy: + r.david.murray

messages: + msg88541
resolution: fixed
stage: patch review
2008-09-11 00:06:05amaury.forgeotdarcsetkeywords: + patch, needs review
files: + trace.patch
messages: + msg72998
2008-09-10 09:36:36amaury.forgeotdarcsetpriority: critical
assignee: amaury.forgeotdarc
messages: + msg72951
nosy: + amaury.forgeotdarc
2008-09-09 16:07:12jjdominguezmcreate