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.
Created on 2010年02月12日 17:29 by Oliver.Jeeves, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Messages (11) | |||
|---|---|---|---|
| msg99273 - (view) | Author: Oliver Jeeves (Oliver.Jeeves) | Date: 2010年02月12日 17:29 | |
When trying to build a python package for distribution, compile errors are always ignored. The setup function will return successfully even if it was unable to compile some modules due to, for example, indentation errors. The specific situation I'm trying to deal with, is a script that builds a large number of eggs, and trying to detect if something went wrong. I see that this has been raised as a bug for setuptools: http://bugs.python.org/setuptools/issue61 But it's not considered an issue because it's how distutils works. distutils.util.byte_compile calls py_compile.compile, but does not pass a doraise argument to it. The only suggestion for how to get tools that use distutils.util.byte_compile (like setuptools.setup and distutils.core.setup) to exit on an error is to monkey patch py_compile.compile to change its default doraise argument to True. That suggestion came from here: http://stackoverflow.com/questions/2230843/how-can-i-detect-errors-programatically-when-building-an-egg-with-setuptools supressing compile errors when making a distribution seems like a bug to me, but just having the option to easily change this behaviour would be great. |
|||
| msg213474 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2014年03月13日 21:22 | |
This may have been done on purpose, to allow nearly-valid Python files to be packaged. In other bug reports we got some use cases: files used as templates; custom dialects converted by import hooks; 2.x and 3.x code in the same sdist. In that light, I think distutils should not raise exceptions (to allow these use cases) but should log warnings (to help people catch legitimate errors). |
|||
| msg213476 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2014年03月13日 21:24 | |
Another use case from #10530: deliberately broken modules for testing. |
|||
| msg213477 - (view) | Author: Donald Stufft (dstufft) * (Python committer) | Date: 2014年03月13日 21:25 | |
It would also break some 2/3 compatible projects who have a python3 and a python2 file sitting next to each other and dynamically selected and imported based on Python version. |
|||
| msg213938 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2014年03月18日 02:52 | |
We all agree Python files with invalid syntax should be allowed, but some error message should be logged. From the py_compile docs, this is already what the compile function does if the doraise argument is false (default), so what’s needed here is a unit test that makes sure we get a warning and the bad file is included in the sdist. (I think we should not be concerned by the direct print to stderr instead of using proper logging: distutils uses its own logging system which lets one control the verbosity but does not have flexible filters, handlers and configuration, so in effect it’s like print to stderr.) |
|||
| msg226285 - (view) | Author: Danek Duvall (dhduvall) | Date: 2014年09月02日 21:55 | |
As a distribution maintainer of several Python modules, I've run into this bug twice in the past week. In each case, the python file in question had a SyntaxError and failed to compile, but the error just scrolled past in a large log and was missed because no failure occurred until we attempted to package the result, and the .pyc files were missing. While we managed to track the problem down fairly easily in both cases, if we only had folks working on the problem that didn't have lots of experience in tracking down build issues, this could have wasted a lot of otherwise valuable engineering time. I understand the desire to be able to package files that fail to compile, but having that be the default seems to me like it fails basic expectations, even given how long this bug has been around. I can't imagine that the number of deliberately-broken python files is particularly large compared to the number of python files that might get broken accidentally (or files that are "broken" for one version of python but not another) and so being required to maintain an exception list doesn't seem unreasonable. (Neither does some amount of transition period -- one or two minor releases of Python? -- between the introduction of the mechanism and the change of the default.) Would people be interested in a patch to that effect? |
|||
| msg226287 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2014年09月02日 22:16 | |
Again, I think this behaviour was a deliberate decision, not a patch. Developers should use tests to detect syntax errors in their code, not rely on distutils byte compilation. |
|||
| msg226288 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2014年09月02日 22:16 | |
a deliberate decision, not a bug* |
|||
| msg226289 - (view) | Author: Danek Duvall (dhduvall) | Date: 2014年09月02日 22:47 | |
Absolutely true that developers should have tests that would detect such bugs. However, the sooner you detect a bug, the more time you save. And by the time it reaches someone like me, who is just packaging up the module for distribution with an OS, it's just going to waste my time, too, with less benefit (because I'm still not going to have much of an incentive to write tests). Imagine if your C compiler only warned about code that wouldn't compile, and failed to produce the corresponding .o file without erroring out, and the linker failed to error out when that .o file was missing, and that you only noticed the problem when you ran your tests (or, if you're just shipping someone else's code, when your customer calls you to complain). Wouldn't you think that was stunningly broken? Again, I get that there are use cases for having broken code pass through unscathed, but it seems very odd to me (as someone with a long unix background) that this would have been a conscious default. Now that it is the default, I understand the need for caution, but caution needn't (and shouldn't) prevent bugs from getting fixed. |
|||
| msg229400 - (view) | Author: Colton Leekley-Winslow (lwcolton) * | Date: 2014年10月15日 03:34 | |
Also agree setup allowing broken code an be annoying, but it is necessary to maintain the existing behavior. Maybe we need an additional argument for setup that will in turn pass doraise to py_compile.compile, but retain the default behavior in all other cases? As a work-around to your problem, try "pylint -E" before you build your package, we require it as a part of our build process. |
|||
| msg348626 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2019年07月29日 11:40 | |
It seems like this issue is not a bug, I close it. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:57 | admin | set | github: 52166 |
| 2019年07月29日 11:40:02 | vstinner | set | status: open -> closed nosy: + vstinner messages: + msg348626 resolution: not a bug stage: needs patch -> resolved |
| 2014年10月15日 03:34:51 | lwcolton | set | nosy:
+ lwcolton messages: + msg229400 |
| 2014年09月02日 22:47:26 | dhduvall | set | messages: + msg226289 |
| 2014年09月02日 22:16:37 | eric.araujo | set | messages: + msg226288 |
| 2014年09月02日 22:16:20 | eric.araujo | set | messages: + msg226287 |
| 2014年09月02日 21:55:58 | dhduvall | set | messages: + msg226285 |
| 2014年09月02日 21:37:41 | dhduvall | set | nosy:
+ dhduvall |
| 2014年03月18日 02:52:36 | eric.araujo | set | messages: + msg213938 |
| 2014年03月13日 21:25:50 | dstufft | set | nosy:
+ dstufft messages: + msg213477 |
| 2014年03月13日 21:24:24 | eric.araujo | set | messages: + msg213476 |
| 2014年03月13日 21:23:27 | eric.araujo | set | messages: - msg122428 |
| 2014年03月13日 21:22:36 | eric.araujo | set | assignee: tarek -> eric.araujo components: + Distutils, - Distutils2 title: distutils always ignores compile errors -> distutils always ignores byte compilation errors keywords: + easy type: enhancement -> behavior versions: + Python 2.7, Python 3.3, Python 3.4, - 3rd party messages: + msg213474 |
| 2010年11月26日 02:15:04 | eric.araujo | set | versions:
+ 3rd party, - Python 3.2 nosy: + eric.araujo messages: + msg122428 components: + Distutils2, - Distutils stage: needs patch |
| 2010年07月10日 23:29:27 | terry.reedy | set | versions: + Python 3.2, - Python 2.6 |
| 2010年02月12日 17:29:06 | Oliver.Jeeves | create | |