[Python-Dev] Can Python implementations reject semantically invalid expressions? (original) (raw)
Mark Dickinson dickinsm at gmail.com
Fri Jul 2 18:26:55 CEST 2010
- Previous message: [Python-Dev] Can Python implementations reject semantically invalid expressions?
- Next message: [Python-Dev] Can Python implementations reject semantically invalid expressions?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, Jul 2, 2010 at 3:44 PM, Craig Citro <craigcitro at gmail.com> wrote:
Whoa. That's very peculiar looking bytecode. Is dis.dis behaving as it should here? BTW, I think you want 'raise TypeError', not 'raise TypeError()'.
Yep, that's embarrassing. I was being lazy: I was expecting different bytecodes, and I got it ... so I apparently didn't bother to actually read the bytecodes? It's interesting -- if I'd just had TypeError instead of TypeError(), I would have found this out, because "raise TypeError" is not the bytes representation of a valid sequence of bytecodes. ;)
Ah; interesting. Well clearly that's exactly what I meant when I said 'raise TypeError' was better than 'raise TypeError()'. ;-)
(Actually, I confess to being similarly embarrassed: I have no idea what I was thinking there, since 'raise TypeError()' is just as valid, if a little less idiomatic.)
That said, I totally concede Martin's point -- this is an implementation-specific thing. It happens that all the major Python implementations compile to some VM, and I'd bet that these two compile to different bytecodes on any of them, but that doesn't preclude another implementation from making a different choice there.
Agreed.
Mark
- Previous message: [Python-Dev] Can Python implementations reject semantically invalid expressions?
- Next message: [Python-Dev] Can Python implementations reject semantically invalid expressions?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]