{"body":"class A:\r\n    def f(self): return 1\r\n\r\ndef callf():\r\n    a = A()\r\n    # warm up method cache\r\n    for i in range(100):\r\n        x = a.f()\r\n    return x\r\n\r\nprint(\"before hack\", callf())\r\n\r\nimport gc\r\nd, = gc.get_referents(A.__dict__) # get the underlying dict from the mappingproxy\r\nd['f'] = lambda self: \"evil\"\r\n\r\nprint(\"after hack\", callf())","name":"","extension":"py","url":"https://www.irccloud.com/pastebin/Rx5HwNWJ","modified":1635683731,"id":"Rx5HwNWJ","size":342,"lines":17,"own_paste":false,"theme":"","date":1635683594}