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 2011年12月03日 12:18 by lennartyseboodt, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| pythonbug.tar.gz | lennartyseboodt, 2011年12月03日 12:18 | |||
| Messages (5) | |||
|---|---|---|---|
| msg148791 - (view) | Author: (lennartyseboodt) | Date: 2011年12月03日 12:18 | |
Python does not warn/error when importing a module where the module.py file no longer exists, but there is still a .pyc file present. It also does not warn when the imported file.py is a symlink pointing nowhere. As long as there is still a .pyc file with the correct name it does not warn/error. Attached is a minimal set to demonstrate. Execute test.py. |
|||
| msg148794 - (view) | Author: Ezio Melotti (ezio.melotti) * (Python committer) | Date: 2011年12月03日 12:27 | |
Python doesn't require the .py to run the code if there's a .pyc. This is expected so there's no need to give a warning. If the .py is present but it's a symlink pointing nowhere, it might make sense to give a warning before falling back silently on the .pyc. |
|||
| msg148820 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2011年12月03日 19:49 | |
Indeed, this is a feature, not a bug. Lone pyc files are used by some people to provide "binary only" distributions of Python software (I'm not really saying it's a good idea, but some people rely on it). As for symlinks, well... This would complicate the code quite a bit and I'm not sure there's really a point to warn about it. |
|||
| msg148826 - (view) | Author: Julian Berman (Julian) * | Date: 2011年12月04日 00:24 | |
I know this is a feature, and on occasion as pointed out a useful one. But in some cases it can be a tad annoying as the OP probably considered it. I had a recent example where a lingering .pyc made my test suite pass (and me nearly push broken code) despite the fact that I'd moved the file away and edited it, with bugs. Obviously I now remember to rebuild and remove all .pyc's before I commit, but it took a near miss to remind me to. Would it be useful to have a command line flag that did something like this (perhaps that test runners could set by default) to prevent others from running into similar situations? |
|||
| msg148831 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2011年12月04日 03:59 | |
In Python 3.2 and later, standalone .pyc files are no longer created as a side effect of import. Instead, cached files are stored in a __pycache__ subdirectory and ignored completely if the corresponding source file is no longer present. (Standalone .pyc files may still be created explicitly for sourceless Python distribution) See PEP 3147 for details. Warnings for accidental use of standalone .pyc files will not be added to earlier versions, since there is no way for Python to tell the difference between accidental and deliberate use. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:24 | admin | set | github: 57732 |
| 2011年12月04日 03:59:13 | ncoghlan | set | status: open -> closed resolution: out of date messages: + msg148831 stage: resolved |
| 2011年12月04日 00:24:06 | Julian | set | nosy:
+ Julian messages: + msg148826 |
| 2011年12月03日 19:49:55 | pitrou | set | nosy:
+ pitrou, brett.cannon, ncoghlan messages: + msg148820 versions: + Python 3.2, Python 3.3 |
| 2011年12月03日 12:27:30 | ezio.melotti | set | nosy:
+ ezio.melotti messages: + msg148794 |
| 2011年12月03日 12:18:57 | lennartyseboodt | create | |