Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.01; 'debug': 0.03; 'happily': 0.07; 'ignored': 0.07; 'imports': 0.07; 'received:verizon.net': 0.07; 'terry': 0.07; 'python': 0.08; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; "hasn't": 0.13; 'subject:file': 0.13; '.py': 0.16; '3.2.': 0.16; 'caveat': 0.16; 'reedy': 0.16; 'rewrites': 0.16; 'roy': 0.16; 'tutorial.': 0.16; 'wrote:': 0.16; '>>>': 0.18; 'url:bugs': 0.18; 'jan': 0.19; 'header:In-Reply-To:1': 0.22; 'globally': 0.23; 'module,': 0.23; 'pep': 0.23; 'welcome.': 0.23; 'subject:use': 0.24; 'right.': 0.25; 'pm,': 0.26; 'import': 0.27; 'noticed': 0.28; 'either.': 0.30; 'usually': 0.30; "i've": 0.31; 'version': 0.31; 'updated': 0.32; 'suggested': 0.32; 'thanks': 0.32; 'it.': 0.33; 'header :User-Agent:1': 0.33; 'to:addr:python-list': 0.33; 'there': 0.33; 'this.': 0.33; 'file.': 0.34; 'doc': 0.34; 'header:X-Complaints- To:1': 0.34; 'something': 0.35; "i'll": 0.35; '(for': 0.35; 'however,': 0.35; 'file': 0.35; 'url:python': 0.36; 'similar': 0.36; 'received:org': 0.37; 'unless': 0.37; "there's": 0.37; 'another': 0.37; 'happens': 0.37; 'some': 0.38; 'put': 0.38; 'subject:with': 0.38; 'url:org': 0.39; 'files': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.40; 'john': 0.62; 'leading': 0.62; 'back': 0.62; '30,': 0.74; 'failures.': 0.84; '3.3': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Disable use of pyc file with no matching py file Date: Tue, 31 Jan 2012 18:43:32 -0500 References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-74-109-121-73.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328053434 news.xs4all.nl 6877 [2001:888:2000:d::a6]:58191 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19663 On 1/31/2012 3:20 PM, John Roth wrote: > On Jan 30, 3:43 pm, 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. I tested before writing this. The caveat is that x.pyc in the same directly as x.py will not be ignored (for back compatibility). However, this only happens intentionally as .pyc files are put in __pycache__/ with name x..pyc, where is 'cpython-32' or something similar for another version or implementation. > I've noticed that the tutorial (section 6.1.3) hasn't been updated for > PEP 3147; there's no way of telling that this is the behavior from > reading the tutorial. The development doc for 3.3 hasn't been updated > either. You are right. An oversight. Thanks for noticing. http://bugs.python.org/issue13915 Suggested rewrites are welcome. -- Terry Jan Reedy