daily pastebin goal
0%
SHARE
TWEET

Trivial Python bytecode hack

a guest Aug 31st, 2010 581 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top