Issue 3435: 3rd party program calls trace.py on non Python files (original) (raw)

Created on 2008-07-24 10:39 by Gustavo, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
trace.diff Gustavo,2008-07-24 10:38 Patch to fix this bug
Messages (4)
msg70197 - (view) Author: Gustavo Narea (Gustavo) Date: 2008-07-24 10:38
trace.py tries to get coverage information from non Python files, which raises a SyntaxError because the file doesn't contain valid Python code. I've attached a path that fixes this problem in Python 2.5.
msg70198 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-07-24 11:08
Your remark is certainly valid, but where does this occur? Some tool that generate python code on the fly? Do you have an example, a use case?
msg70199 - (view) Author: Gustavo Narea (Gustavo) Date: 2008-07-24 11:19
Hi, Amaury. I found this problem using the Bitten continuous integration system (http://bitten.edgewall.org/ticket/304). I'm using the TurboGears framework with Genshi, and therefore mypackage.templates module should contain non-Python files. Here you'll find its contents: https://tracker.gnulinuxmatters.org/browser/animador/trunk/animador/template This is the only situation where the problem occurs, AFAIK. If you want to reproduce it, you can: 1.- Install Bitten: easy_install http://svn.edgewall.org/repos/bitten/trunk/ 2.- Install my package: svn co https://svn.gnulinuxmatters.org:81/animador/trunk/ animador cd animador ./setup.py develop 3.- Run Bitten's "unittest" extension for setuptools under my package with the following options: ./setup.py unittest --xml-output build/test-results.xml --coverage-summary build/test-coverage.txt --coverage-dir build/coverage Then you'll get a SyntaxError if the patch I attached is not applied. Cheers.
msg139214 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-06-26 20:41
The patch adds this check: + if not filename.endswith((".pyc", ".pyo", ".py")): + continue This is not valid. A Python file is a text file with python code. In spite of import conventions, they are not required to have any particular extension and some people omit them from main scripts. Trace works fine with such files now and your patch would prevent that. Python files are only identified as such by trying to parse them. The problem and solution lie with your setup. Arrange things so Bitten only treats Python files as Python files.
History
Date User Action Args
2022-04-11 14:56:36 admin set github: 47685
2011-06-26 20:41:13 terry.reedy set status: open -> closedtitle: trace.py tries to get coverage data from non Python files -> 3rd party program calls trace.py on non Python filesnosy: + terry.reedyversions: + Python 2.7, Python 3.2, - Python 2.6, Python 3.1messages: + resolution: not a bugstage: test needed -> patch review
2009-05-16 20:38:10 ajaksu2 set priority: normalstage: test neededversions: + Python 2.6, Python 3.1, - Python 2.5
2008-10-17 21:36:01 jerry.seutter set nosy: + jerry.seutter
2008-07-24 11:19:23 Gustavo set messages: +
2008-07-24 11:08:07 amaury.forgeotdarc set nosy: + amaury.forgeotdarcmessages: +
2008-07-24 10:39:00 Gustavo create