Last active
March 29, 2017 18:40
-
-
Save o11c/4527b22a6e2a03c699443bef2b5db900 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| GLOBAL = 'main' | |
| import foo | |
| import types | |
| def p(self, x): | |
| return 'p: fixed ' + GLOBAL | |
| foo.Parent.p = types.FunctionType(p.__code__, foo.Parent.p.im_func.__globals__, argdefs=foo.Parent.p.im_func.__defaults__) | |
| def c(self, x): | |
| return 'child.c: fixed ' + GLOBAL | |
| foo.Parent.c = types.FunctionType(p.__code__, foo.Child.__dict__['c'].__globals__, argdefs=foo.Child.__dict__['c'].__defaults__) | |
| def qux(x): | |
| return 'qux: fixed ' + GLOBAL | |
| foo.qux = types.FunctionType(qux.__code__, foo.qux.__globals__, argdefs=foo.qux.__defaults__) | |
| if __name__ == '__main__': | |
| foo.main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| GLOBAL = 'library' | |
| class Parent(object): | |
| def p(self, x=1): | |
| return 'p: buggy ' + GLOBAL | |
| def c(self, x=1): | |
| return 'c: buggy ' + GLOBAL | |
| class Child(Parent): | |
| def p(self, x=1): | |
| return 'child.' + Parent.p(self) | |
| def c(self, x=1): | |
| return 'child.' + Parent.c(self) | |
| def qux(x=1): | |
| return 'qux: buggy ' + GLOBAL | |
| def main(): | |
| print(Child().p()) | |
| print(Child().c()) | |
| print(qux()) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment