Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'say,': 0.05; 'subject:Python': 0.06; 'sys': 0.07; 'attributes': 0.09; 'overwrite': 0.09; 'api': 0.11; 'cc:addr:python-list': 0.11; 'python': 0.11; 'random': 0.14; 'changes': 0.15; 'attributes.': 0.16; 'caveat': 0.16; 'file-like': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'reasonably': 0.16; 'sys.stdout': 0.16; 'there?': 0.16; 'top-level': 0.16; 'who?': 0.16; 'worst': 0.16; 'weird': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'library': 0.18; 'all,': 0.19; 'module': 0.19; 'replacing': 0.19; 'version.': 0.19; 'command': 0.22; '>>>': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'replace': 0.24; 'cc:2**0': 0.24; 'developers': 0.25; 'options': 0.25; 'script': 0.25; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'that.': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'subject:some': 0.31; 'there.': 0.32; 'me?': 0.32; 'another': 0.32; 'open': 0.33; 'running': 0.33; 'fri,': 0.33; 'maybe': 0.34; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'object,': 0.36; 'should': 0.36; 'being': 0.38; 'anything': 0.39; 'explain': 0.39; 'bad': 0.39; 'even': 0.60; 'remove': 0.60; 'future': 0.60; 'course': 0.61; "you're": 0.61; 'you.': 0.62; 'more': 0.64; 'afraid': 0.65; 'friends': 0.81; '"can': 0.84; 'hardly': 0.84; 'streams': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=eXy9ABlQ+KuWHN1iN6p4XOlsqra3shzgwoKKV3FPSkI=; b=pgMj4ocwS+0MlziGkRkHvhT8njdeF+R0x8aZ+S3ooWD2fN56QOrjU6Jcj2Skc9y12K IKtcZZEl7kD11P066np6z8GbE5ZdxDkIHlud+F//pyCUo4euiDGqx8oI3H2a7I3+34Ld Ufjv4d6J67tLXO2OtWPcuZkTdZK6wX87TI8XDJH0mR/9eDNCAqqGVa+ADi4+0rJliRuD fkvzwdKjDRFLeMLeLitAKZ3mo9drxNSiMT02KrMSBVAxJwNUX/bqprbcGEgJdwuxspUm +KSLwsnwZXvvmAaTvJiy8tEOVjDUGzkrrAjW4oSVJv5QnQb9RAWMEdyDWzqjZJHLZyYz rzow== MIME-Version: 1.0 X-Received: by 10.58.74.201 with SMTP id w9mr1154363vev.56.1402011595065; Thu, 05 Jun 2014 16:39:55 -0700 (PDT) In-Reply-To: <87ioof53z1.fsf@elektro.pacujo.net> References: <538bcfff$0$29978$c3e8da3$5496439d@news.astraweb.com> <538C5BB8.1020702@chamonix.reportlab.co.uk> <538f1a61$0$29978$c3e8da3$5496439d@news.astraweb.com> <87a99r7rmx.fsf@elektro.pacujo.net> <871tv37pdt.fsf@elektro.pacujo.net> <87sinju1hf.fsf@elektro.pacujo.net> <8738fjumy8.fsf@elektro.pacujo.net> <5390f997$0$29978$c3e8da3$5496439d@news.astraweb.com> <87ioof53z1.fsf@elektro.pacujo.net> Date: Fri, 6 Jun 2014 09:39:54 +1000 Subject: Re: Python 3.2 has some deadly infection From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1402011598 news.xs4all.nl 2934 [2001:888:2000:d::a6]:60013 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:72792 On Fri, Jun 6, 2014 at 9:30 AM, Marko Rauhamaa wrote: > Steven D'Aprano : > >>> "Can be replaced" by who? By the Python developers? By me? By random >>> library calls? >> >> By you. sys.stdout and friends are writable. Any code you call may >> have replaced them with another file-like object, and you should >> honour that. > > I can of course overwrite even sys and os and open and all. That hardly > merits mentioning in the API documentation. > > What I'm afraid of is that the Python developers are reserving the right > to remove the buffer and detach attributes from the standard streams in > a future version. That would be terrible. > > If it means some other module is allowed to commandeer the standard > streams, that would be bad as well. > > Worst of all, I don't know why the caveat had to be there. > > Or is it maybe because some python command line options could cause > buffer and detach not to be there? That would explain the caveat, but > still would be kinda sucky. It's more that replacng sys.std* is considered reasonably normal (unlike, say, replacing sys.float_info, which would be a weird thing to do); and you could replace them with something that doesn't have those attributes. If you're running a top-level script and you never import anything that changes the streams, you should be able to depend on those always being there. ChrisA