Disable use of pyc file with no matching py file

Jean-Michel Pichavant jeanmichel at sequans.com
Tue Jan 31 09:19:13 EST 2012


Steven D'Aprano wrote:
> On Tue, 31 Jan 2012 11:26:10 +0100, Jean-Michel Pichavant wrote:
>
>   
>> Terry Reedy wrote:
>>     
>>> On 1/30/2012 4:30 PM, Roy Smith wrote:
>>>       
>>>> Every so often (typically when refactoring), I'll remove a .py file
>>>> and forget to remove the corresponding .pyc file.  If I then import
>>>> the module, python finds the orphaned .pyc and happily imports it.
>>>> Usually leading to confusing and hard to debug failures.
>>>>
>>>> Is there some way to globally tell python, "Never import a .pyc unless
>>>> the corresponding .py file exits"?
>>>>         
>>> Upgrade to 3.2.
>>>
>>>       
>> No.
>>     
>
>
> Is that intended as "No, I won't upgrade" or "No, Python 3.2 doesn't do 
> the job"?
>   
To answer Ben's mail as well, the "No" would be more of the "don't do 
it". My answer was as argued as Terry's one anyway (it was quite intended).
Steven, you often use analogies/similarities, here's one:

A: "My wheel is flat"
B: "Buy a new car"

Buying a new car would solve A's problem : yes
Should A buy a new car : probably no

Python 3.2 is fine, but someone could run into several issues while 
migrating. This is quite a pretty huge decision to make (I dedicate this 
sentence to Rick, I hope he's trolling fine).

JM







More information about the Python-list mailing list