Title: 3rd party program calls on non Python files
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.2, Python 2.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Gustavo, amaury.forgeotdarc, jerry.seutter, terry.reedy
Priority: normal Keywords: patch

Created on 2008-07-24 10:39 by Gustavo, last changed 2011-06-26 20:41 by terry.reedy. This issue is now closed.

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 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

I'm using the TurboGears framework with Genshi, and therefore
mypackage.templates module should contain non-Python files. Here you'll find
its contents:

This is the only situation where the problem occurs, AFAIK.

If you want to reproduce it, you can:
 1.- Install Bitten:
 2.- Install my package:
svn co animador
cd animador
./ develop
 3.- Run Bitten's "unittest" extension for setuptools under my package with the
following options:
./ 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.

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.
Date User Action Args
2011-06-26 20:41:13terry.reedysetstatus: open -> closed

title: tries to get coverage data from non Python files -> 3rd party program calls on non Python files
nosy: + terry.reedy
versions: + Python 2.7, Python 3.2, - Python 2.6, Python 3.1
messages: + msg139214
resolution: not a bug
stage: test needed -> patch review
2009-05-16 20:38:10ajaksu2setpriority: normal
stage: test needed
versions: + Python 2.6, Python 3.1, - Python 2.5
2008-10-17 21:36:01jerry.seuttersetnosy: + jerry.seutter
2008-07-24 11:19:23Gustavosetmessages: + msg70199
2008-07-24 11:08:07amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg70198
2008-07-24 10:39:00Gustavocreate