Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #30999

Re: [Python-ideas] Make "is" checks on non-singleton literals errors

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feed.xsnews.nl!border-2.ams.xsnews.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
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:: [': 0.03; 'argument': 0.04; 'subject:Python': 0.05; 'compiler': 0.05; 'guido': 0.05; '"if': 0.09; 'branches': 0.09; 'literal': 0.09; 'rossum': 0.09; "wouldn't": 0.11; ':-)': 0.13; "(i'm": 0.16; 'bytecode': 0.16; 'closely.': 0.16; 'drastic': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'merely': 0.16; 'oct': 0.16; 'rejected.': 0.16; 'subject:ideas': 0.16; 'subject:non': 0.16; 'wrote:': 0.17; 'tests': 0.18; 'subject:] ': 0.19; 'assumes': 0.22; 'constant': 0.22; 'new,': 0.22; 'occurs': 0.22; 'work,': 0.22; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com': 0.27; 'proposing': 0.29; 'van': 0.29; 'maybe': 0.29; 'that.': 0.30; 'checks': 0.30; 'writes': 0.30; 'code': 0.31; 'could': 0.32; 'true.': 0.33; 'to:addr:python- list': 0.33; 'everyone': 0.33; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'except': 0.36; 'but': 0.36; 'subject:" ': 0.36; 'test': 0.36; 'should': 0.36; 'enough': 0.36; 'received:209': 0.37; 'unit': 0.38; 'to:addr:python.org': 0.39; 'easily': 0.39; 'subject:-': 0.40; 'header:Received:5': 0.40; 'leading': 0.61; 'more': 0.63; 'dangerous': 0.66; 'unusual': 0.71; 'subject:Make': 0.91; 'examine': 0.95
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:to :content-type; bh=yfOBC2FmeoMSPxJgZZXTV0TdCw9VwG3U7hXGDPJsgd0=; b=zr/GihWmXQskHxahVfgVEOHIVmqdENuNGUnSocbvfIUAcMc3qr7mQF7Uy/8BRaiMdZ sdkmcrbt0qwRA+WED2xhHLbpzDqljQPE8LcSgH9tTGxQr9MmDHGCbndGxYpkzgtoUQID XpY/m+lEBDqOCcXe2r74UnNaAUdphcBvq+9xWIaXA4BdVoX7ZRcoIcp9dEcfL9Tao0vP ZhxZOrUCfve1KcBzPejwrqAJRu2MDBX/9+T6t0jCVkxvr31q+bCpJBBb6AVboHyPknkM LRD+cn97wM1tEaD28bFihIXRZK8sMpEGFizV8YetgHPBEYsE8+p0rStw62nFK6+YVqKQ /mbg==
MIME-Version 1.0
In-Reply-To <CAP7+vJJkcHXN+Jf2COuTOvj4NVkrNG6f9W+dwSW89_i4DRcEoQ@mail.gmail.com>
References <CAEBZo3PhCXURW1FWpmSQYpUj7DrquXfjuF7xztFHFd4TymNjsQ@mail.gmail.com> <CAP7+vJJRhp8Nm+LJrqmo1aR92_rNRf2T-Jm3+Rt9kiCrp0QNMQ@mail.gmail.com> <20121009020327.GB27445@ando> <CAP7+vJJkcHXN+Jf2COuTOvj4NVkrNG6f9W+dwSW89_i4DRcEoQ@mail.gmail.com>
Date Tue, 9 Oct 2012 18:06:13 +1100
Subject Re: [Python-ideas] Make "is" checks on non-singleton literals errors
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1983.1349766382.27098.python-list@python.org> (permalink)
Lines 16
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1349766382 news.xs4all.nl 6854 [2001:888:2000:d::a6]:50714
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:30999

Show key headers only | View raw


On Tue, Oct 9, 2012 at 1:14 PM, Guido van Rossum <guido@python.org> wrote:
> Maybe we should do something more drastic and always create a new,
> unique constant whenever a literal occurs as an argument of 'is' or
> 'is not'? Then such code would never work, leading people to examine
> their code more closely. I betcha we have people who could change the
> bytecode compiler easily enough to do that. (I'm not seriously
> proposing this, except as a threat of what we could do if the
> SyntaxWarning is rejected. :-)

That wouldn't guarantee that the code would never work, merely that
the 'is' checks would be never true. Dangerous if the condition is a
guard for an unusual condition. A unit test could of course catch it,
but that assumes that everyone who writes "if x is 0" has tests
probing both branches of that check...

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: [Python-ideas] Make "is" checks on non-singleton literals errors Chris Angelico <rosuav@gmail.com> - 2012-10-09 18:06 +1100

csiph-web