/Lib/test/crashers/bogus_code_obj.py

http://unladen-swallow.googlecode.com/ · Python · 19 lines · 11 code · 0 blank · 8 comment · 0 complexity · 5e84429cfdb949a97a7c5d77b2eea8ae MD5 · raw file

  1. """
  2. Broken bytecode objects can easily crash the interpreter.
  3. This is not going to be fixed. It is generally agreed that there is no
  4. point in writing a bytecode verifier and putting it in CPython just for
  5. this. Moreover, a verifier is bound to accept only a subset of all safe
  6. bytecodes, so it could lead to unnecessary breakage.
  7. For security purposes, "restricted" interpreters are not going to let
  8. the user build or load random bytecodes anyway. Otherwise, this is a
  9. "won't fix" case.
  10. """
  11. import types
  12. co = types.CodeType(0, 0, 0, 0, '\x04\x71\x00\x00', (),
  13. (), (), '', '', 1, '')
  14. exec co