On Tue, Jun 3, 2014 at 1:38 AM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > On Mon, 02 Jun 2014 23:23:53 +1000, Chris Angelico wrote: > >> On Mon, Jun 2, 2014 at 10:27 PM, Tim Chase >> <python.l...@tim.thechases.com> wrote: >>> Stripping off the exec() call makes it pretty transparent that you're >>> attempting (successfully on some platforms) to set the value of "4" to >>> "5". But a cute hack. >> >> And not on Windows inside IDLE, where attempting to use 4 results in a >> ===== RESTART ===== crash. > > Sounds like a bug in IDLE. > > What happens if you try it in Windows without IDLE, just using the > standard interactive interpreter?
It works fine without IDLE. Python 2.7.4 (default, Apr 6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)] on win 32 >>> exec((lambda *fs: reduce(lambda f, g: lambda x: f(g(x)), fs))(*([lambda s: s [1::2]+s[-2::-2]]*54))('motcye;cye._n8fo_drs(d4+)vle=5 ua.8)(isedamr.ticspt spt rpi')) >>> 10 - 6 == 10 - 5 True In IDLE: >>> exec((lambda *fs: reduce(lambda f, g: lambda x: f(g(x)), fs))(*([lambda s: >>> s[1::2]+s[-2::-2]]*54))('motcye;cye._n8fo_drs(d4+)vle=5 >>> ua.8)(isedamr.ticspt spt rpi')) >>> 10 - 6 == 10 - 5 >>> ================================ RESTART ================================ There's a bit of a pause before the RESTART line comes through, and repeating the equality check after that comes back with a straight-forward False. Running IDLE from a terminal gives this: C:\Documents and Settings\M>\python27\python -m idlelib.idle ---------------------------------------- Unhandled server exception! Thread: SockThread Client Address: ('127.0.0.1', 4414) Request: <socket._socketobject object at 0x0127ADC0> Traceback (most recent call last): File "C:\python27\lib\SocketServer.py", line 295, in _handle_request_noblock self.process_request(request, client_address) File "C:\python27\lib\SocketServer.py", line 321, in process_request self.finish_request(request, client_address) File "C:\python27\lib\SocketServer.py", line 334, in finish_request self.RequestHandlerClass(request, client_address, self) File "C:\python27\lib\idlelib\rpc.py", line 503, in __init__ SocketServer.BaseRequestHandler.__init__(self, sock, addr, svr) File "C:\python27\lib\SocketServer.py", line 649, in __init__ self.handle() File "C:\python27\lib\idlelib\run.py", line 268, in handle rpc.RPCHandler.getresponse(self, myseq=None, wait=0.05) File "C:\python27\lib\idlelib\rpc.py", line 280, in getresponse response = self._getresponse(myseq, wait) File "C:\python27\lib\idlelib\rpc.py", line 300, in _getresponse response = self.pollresponse(myseq, wait) File "C:\python27\lib\idlelib\rpc.py", line 424, in pollresponse message = self.pollmessage(wait) File "C:\python27\lib\idlelib\rpc.py", line 376, in pollmessage packet = self.pollpacket(wait) File "C:\python27\lib\idlelib\rpc.py", line 357, in pollpacket self._stage0() File "C:\python27\lib\idlelib\rpc.py", line 364, in _stage0 self.bufneed = struct.unpack("<i", s)[0] error: unpack requires a string argument of length 4 *** Unrecoverable, server exiting! ---------------------------------------- So... I'd say this isn't so much a bug in IDLE as a limitation: "depends on the universe being sane". I mean, honestly. You just changed the meaning of four! :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list