S Murthy <smur...@pm.me> added the comment:
Yes, I know that a method body may contain more than just the return statement - I was referrring to the byte code for the method def f(x): return x**2. I don't think the output of dis.dis is correct here for the source string of f - it doesn't make sense for example to iterate over Bytecode(f) and get only the instruction for the return statement, but then iterate over Bytecode(inspect.getsource(f)) to get only the byte code for the def - the documentation for dis.dis and Bytecode indicate that all the bytecode for a piece of code, whether specified as a method, callable, generator, async. generator, coroutine, class, or a source string, will be generated. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39800> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com