[issue37166] inspect.findsource doesn't handle shortened files gracefully

2020-12-04 Thread Irit Katriel
Irit Katriel added the comment: Fixed under issue17735. -- nosy: +iritkatriel stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue37166] inspect.findsource doesn't handle shortened files gracefully

2020-12-04 Thread Irit Katriel
Change by Irit Katriel : -- resolution: -> duplicate superseder: -> inspect.findsource raises IndexError ___ Python tracker ___

[issue37166] inspect.findsource doesn't handle shortened files gracefully

2019-06-28 Thread Michael Bejda
Michael Bejda added the comment: I don't think linecache.checkcache helps here. In your example, it would detect the modification, but I don't see how it could persist data if the compilation and execution are different processes. -- ___ Python

[issue37166] inspect.findsource doesn't handle shortened files gracefully

2019-06-28 Thread Michael Bejda
Michael Bejda added the comment: I do not believe it is specific to the way we package things: $ cat a.py: import inspect def foo(): pass inspect.getsource(foo) $ python3 -m compileall -b a.py $ black a.py # to remove the empty lines $ python3 a.pyc # Index error Traceback (most

[issue37166] inspect.findsource doesn't handle shortened files gracefully

2019-06-17 Thread STINNER Victor
STINNER Victor added the comment: If the file content changed, I'm not sure that the folloing heuristic will always find the expected function: lnum = object.co_firstlineno - 1 pat = re.compile(r'^(\s*def\s)|(\s*async\s+def\s)|(.*(? 0: if pat.match(lines[lnum]):

[issue37166] inspect.findsource doesn't handle shortened files gracefully

2019-06-17 Thread STINNER Victor
STINNER Victor added the comment: inspect.getsource() starts with linecache.checkcache(file) which if the file modification time changed or if the file size changed. Using regular files on disk, I don't see how this bug is possible: $ cat x.py import inspect import os import linecache

[issue37166] inspect.findsource doesn't handle shortened files gracefully

2019-06-05 Thread Michael Bejda
Change by Michael Bejda : -- keywords: +patch pull_requests: +13727 stage: -> patch review pull_request: https://github.com/python/cpython/pull/13850 ___ Python tracker ___

[issue37166] inspect.findsource doesn't handle shortened files gracefully

2019-06-05 Thread SilentGhost
SilentGhost added the comment: 3.6 is in security-only mode, this doesn't look like a security issue to me -- nosy: +SilentGhost, yselivanov versions: +Python 3.9 -Python 3.6 ___ Python tracker

[issue37166] inspect.findsource doesn't handle shortened files gracefully

2019-06-05 Thread Tim Hatch
Change by Tim Hatch : -- type: -> behavior ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue37166] inspect.findsource doesn't handle shortened files gracefully

2019-06-05 Thread Tim Hatch
New submission from Tim Hatch : inspect.findsource() can trigger IndexError when co_firstlineno is larger than len(linecache.getlines()). If you have a situation where the file that linecache finds doesn't match the imported module, then you're not guaranteed that co_firstlineno on the code