[issue28121] If module starts with comment or empty line then frame.f_code.co_firstlineno is inconsistent with inspect.findsource

2017-02-23 Thread Aivar Annamaa
Aivar Annamaa added the comment: Looks like I misinderstood inspect.findsource. I thought it is supposed to give only the code for argument object (eg. only def code when given a function), but looks like it is giving the whole file. Unfortunately inspect.findsource is not documented in

[issue28121] If module starts with comment or empty line then frame.f_code.co_firstlineno is inconsistent with inspect.findsource

2017-02-23 Thread Louie Lu
Louie Lu added the comment: Sorry, but I can't reproduce at 3.7, 3.5, or 2.7. the result shows me that inspect does respect comment line. ➜ cpython git:(350) ✗ ./python /tmp/main.py 2 (['# First line\n', 'import inspect\n', 'frame = inspect.currentframe()\n',

[issue28121] If module starts with comment or empty line then frame.f_code.co_firstlineno is inconsistent with inspect.findsource

2017-02-21 Thread Emily Morehouse
Changes by Emily Morehouse : -- nosy: +emilyemorehouse ___ Python tracker ___ ___

[issue28121] If module starts with comment or empty line then frame.f_code.co_firstlineno is inconsistent with inspect.findsource

2016-09-13 Thread SilentGhost
Changes by SilentGhost : -- nosy: +yselivanov ___ Python tracker ___ ___

[issue28121] If module starts with comment or empty line then frame.f_code.co_firstlineno is inconsistent with inspect.findsource

2016-09-13 Thread Aivar Annamaa
Changes by Aivar Annamaa : -- components: +Interpreter Core type: -> behavior versions: +Python 3.5 ___ Python tracker ___

[issue28121] If module starts with comment or empty line then frame.f_code.co_firstlineno is inconsistent with inspect.findsource

2016-09-13 Thread Aivar Annamaa
New submission from Aivar Annamaa: Following program shows that frame.f_code.co_firstlineno ignores first line if it is a comment (or empty line), but inspect.getsource(frame.f_code) returns also the first line: # first line import inspect frame = inspect.currentframe()