Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!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; 'subject:Python': 0.05; 'dependency': 0.07; 'globals': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sep': 0.09; 'terry': 0.09; 'bug': 0.10; 'descriptor.': 0.16; 'exposes': 0.16; 'from:addr:pitrou.net': 0.16; 'from:addr:solipsis': 0.16; 'from:name:antoine pitrou': 0.16; "function's": 0.16; 'message-id:@post.gmane.org': 0.16; 'received:213.41.240': 0.16; 'received:213.41.240.54': 0.16; 'received:80.91.229.3': 0.16; 'received:charlus.yi.org': 0.16; 'received:plane.gmane.org': 0.16; 'received:yi.org': 0.16; 'reedy': 0.16; 'replaced.': 0.16; 'threads': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'module': 0.19; 'this:': 0.23; 'header:User- Agent:1': 0.26; 'am,': 0.27; 'header:X-Complaints-To:1': 0.28; 'chris': 0.28; 'writes:': 0.29; 'function': 0.30; 'file': 0.32; 'comments': 0.33; 'to:addr:python-list': 0.33; 'open': 0.35; 'received:org': 0.36; 'but': 0.36; 'depends': 0.36; "didn't": 0.36; 'charset:us-ascii': 0.36; 'why': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'subject:-': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'most': 0.61; 'subject:The': 0.71; 'antoine.': 0.84; 'opener': 0.84; 'url:pro': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Antoine Pitrou Subject: Re: The opener parameter of Python 3 open() built-in Date: Thu, 6 Sep 2012 00:34:56 +0000 (UTC) References: <504555a5$0$29978$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 213.41.240.54 (Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346891710 news.xs4all.nl 6883 [2001:888:2000:d::a6]:46575 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28546 Chris Angelico gmail.com> writes: > > On Wed, Sep 5, 2012 at 5:16 AM, Terry Reedy udel.edu> wrote: > > io.open depends on a function the returns an open file descriptor. opener > > exposes that dependency so it can be replaced. > > I skimmed the bug report comments but didn't find an answer to this: > Why not just monkey-patch? When a module function calls on a support > function and you want to change that support function's behaviour, > isn't monkey-patching the most usual? Monkey-patching globals is not thread-safe: other threads will see your modification, which is risky and fragile. Regards Antoine. -- Software development and contracting: http://pro.pitrou.net