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

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 2012-10-09 18:06 +1100
Subject Re: [Python-ideas] Make "is" checks on non-singleton literals errors
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1983.1349766382.27098.python-list@python.org> (permalink)

Show all headers | 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