On Fri, Jul 2, 2010 at 8:22 AM, Mark Dickinson <dicki...@gmail.com> wrote: > On Fri, Jul 2, 2010 at 7:55 AM, Craig Citro <craigci...@gmail.com> wrote: >> >>>>> dis.dis("raise TypeError()") >> 0 <114> 26977 >> 3 <115> 8293 >> 6 IMPORT_STAR >> 7 SETUP_EXCEPT 25968 (to 25978) >> 10 <69> >> 11 <114> 28530 >> 14 <114> 10536 >>>>> dis.dis("1 + '1'") >> 0 <49> >> 1 SLICE+2 >> 2 STORE_SLICE+3 >> 3 SLICE+2 >> 4 <39> >> 5 <49> >> 6 <39> > > Whoa. That's very peculiar looking bytecode. Is dis.dis behaving as > it should here?
Ah. I see. It looks like the string "raise TypeError()" is being interpreted *directly* as Python bytecode, with no intermediate compilation. I don't think this is what you intended. Try: >>> dis.dis(compile("raise TypeError", "", "exec")) 1 0 LOAD_NAME 0 (TypeError) 3 RAISE_VARARGS 1 6 LOAD_CONST 0 (None) 9 RETURN_VALUE >>> dis.dis(compile("1 + '1'", "", "exec")) 1 0 LOAD_CONST 0 (1) 3 LOAD_CONST 1 ('1') 6 BINARY_ADD 7 POP_TOP 8 LOAD_CONST 2 (None) 11 RETURN_VALUE Mark _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com