Advertisement
Guest User

Trivial Python bytecode hack

a guest
Aug 31st, 2010
1,155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. >>> c = compile("1", "", "eval")
  2. >>> dis.dis(c)
  3.   1           0 LOAD_CONST               0 (1)
  4.               3 RETURN_VALUE        
  5. >>> eval(c)
  6. 1
  7. >>> c2 = type(c)(c.co_argcount, c.co_kwonlyargcount, c.co_nlocals, c.co_stacksize, c.co_flags, c.co_code[:3], c.co_consts, c.co_names, c.co_varnames, c.co_filename, c.co_name, c.co_firstlineno, c.co_lnotab)
  8. >>> dis.dis(c2)
  9.   1           0 LOAD_CONST               0 (1)
  10. >>> eval(c2)
  11. XXX lineno: 1, opcode: 100
  12. Traceback (most recent call last):
  13.   File "<stdin>", line 1, in <module>
  14.   File "", line 1, in <module>
  15. SystemError: unknown opcode
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement