[issue19956] inspect.getsource(obj.foo) fails when foo is an injected method constructed from another method

2020-05-17 Thread Terry J. Reedy
Terry J. Reedy added the comment: Here is minimal reproducing code. import types import inspect class A: def say(self): print("A.say") a = A() class B: pass b = B() b.say = types.MethodType(a.say, b) Let us examine MethodType first. Calling 'b.say()' asks the previously neglected

[issue19956] inspect.getsource(obj.foo) fails when foo is an injected method constructed from another method

2020-05-11 Thread Terry J. Reedy
Terry J. Reedy added the comment: I am working on an explanation of why I paused the PR. -- versions: +Python 3.9 -Python 3.5 ___ Python tracker ___ __

[issue19956] inspect.getsource(obj.foo) fails when foo is an injected method constructed from another method

2020-05-10 Thread Furkan Onder
Furkan Onder added the comment: PR has been sent. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:/

[issue19956] inspect.getsource(obj.foo) fails when foo is an injected method constructed from another method

2020-05-10 Thread Furkan Onder
Change by Furkan Onder : -- nosy: +furkanonder nosy_count: 6.0 -> 7.0 pull_requests: +19335 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/20025 ___ Python tracker ___

[issue19956] inspect.getsource(obj.foo) fails when foo is an injected method constructed from another method

2017-06-18 Thread Terry J. Reedy
Terry J. Reedy added the comment: Any review of the revised patch? -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubsc

[issue19956] inspect.getsource(obj.foo) fails when foo is an injected method constructed from another method

2015-04-14 Thread Usman Ehtesham Gul
Usman Ehtesham Gul added the comment: Made changes based on David Murray's review comments including adding unit test on getfile. -- Added file: http://bugs.python.org/file39022/issue_19956_1.patch ___ Python tracker

[issue19956] inspect.getsource(obj.foo) fails when foo is an injected method constructed from another method

2015-04-13 Thread R. David Murray
R. David Murray added the comment: Thanks for the patch. I've made some review comments on the tests. -- nosy: +r.david.murray ___ Python tracker ___ ___

[issue19956] inspect.getsource(obj.foo) fails when foo is an injected method constructed from another method

2015-04-13 Thread Usman Ehtesham Gul
Usman Ehtesham Gul added the comment: After discussing with Eric Snow, this case scenario is an edge case. The assumption in the inspect module is that __func__ for a MethodType object is a function. The MethodType should be used for functions and not methods. Patch attached for this. This ne

[issue19956] inspect.getsource(obj.foo) fails when foo is an injected method constructed from another method

2013-12-13 Thread Terry J. Reedy
Terry J. Reedy added the comment: I do not think you have exactly identified a bug, certainly not one we would fix in an existing release. The behavior in more of an unintended consequence of separate decisions resulting from an unanticipated usage. I am not sure what, if anything, should be d

[issue19956] inspect.getsource(obj.foo) fails when foo is an injected method constructed from another method

2013-12-12 Thread Muhammad Tauqir Ahmad
Muhammad Tauqir Ahmad added the comment: Yes I understand your change and other possible changes will fix the reproducer. I am already using a different workaround in my code. The issue is about `inspect.getsource()` having incorrect behavior (or at least inaccurate error message) and MethodTy

[issue19956] inspect.getsource(obj.foo) fails when foo is an injected method constructed from another method

2013-12-12 Thread Vajrasky Kok
Vajrasky Kok added the comment: FYI, if you change: setattr(b, 'say', types.MethodType(f.say, b)) to: setattr(b, 'say', types.MethodType(Foo.say, b)) it will print the source correctly. -- nosy: +vajrasky ___ Python tracker

[issue19956] inspect.getsource(obj.foo) fails when foo is an injected method constructed from another method

2013-12-11 Thread Muhammad Tauqir Ahmad
New submission from Muhammad Tauqir Ahmad: If a method `foo` of object instance `obj` is injected into it using a method from a different object instance, `inspect.getsource(obj.foo)` fails with the error message: TypeError: > is not a module, class, method, function, traceback, frame, or cod