Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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; 'importing': 0.05; 'url:bitbucket': 0.05; 'modify': 0.07; 'imported': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'testing,': 0.09; 'changes': 0.15; 'appengine': 0.16; 'globals': 0.16; 'itself,': 0.16; 'merely': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:where': 0.16; 'url:py': 0.16; 'fix': 0.17; 'module': 0.19; 'url:default': 0.19; 'import': 0.22; 'hack': 0.22; 'putting': 0.22; 'header:User-Agent:1': 0.23; 'proxy': 0.24; 'sort': 0.25; 'possibly': 0.26; 'header:X -Complaints-To:1': 0.27; 'testing': 0.29; 'skip:g 30': 0.30; "i'm": 0.30; 'supposed': 0.32; 'guess': 0.33; 'could': 0.34; 'but': 0.35; 'there': 0.35; 'version': 0.36; 'url:org': 0.36; 'level': 0.37; 'to:addr:python-list': 0.38; 'issue': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'more': 0.64; 'received:109': 0.72 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Robin Becker Subject: where to put global testing value Date: Tue, 29 Apr 2014 17:17:10 +0100 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 109.174.168.73 User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1398788252 news.xs4all.nl 2861 [2001:888:2000:d::a6]:44254 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70716 A user complains that under AppEngine I'm not allowed to import __main__. I can fix this issue merely by putting a try block around the offending import which is only used like this import __main__ testing = getattr(__main__,'_rl_testing',False) del __main__ this is only used as a hack way, during testing, to modify the behaviour of the importing module (a proxy for a C extension). During testing we keep both the C version and the supposed replacement of various functions so they can be tested against each other https://bitbucket.org/rptlab/reportlab/src/default/src/reportlab/lib/rl_accel.py Is there a more reasonable way to allow changes to module level globals before the import takes place? I guess since this module is supposed only to be imported by reportlab we can put this sort of thing onto the reportlab module itself, but that could possibly lead to import loops. Any ideas? -- Robin Becker