[issue45563] inspect.getframeinfo() doesn't handle frames without lineno

2022-03-22 Thread Mark Shannon
Mark Shannon added the comment: You are on own if you create code objects by calling `types.CodeType`. The docs could be a lot clearer about that, though. -- ___ Python tracker

[issue45563] inspect.getframeinfo() doesn't handle frames without lineno

2022-03-22 Thread Thomas Grainger
Change by Thomas Grainger : -- keywords: +patch nosy: +graingert nosy_count: 4.0 -> 5.0 pull_requests: +30134 stage: resolved -> patch review pull_request: https://github.com/python/cpython/pull/32044 ___ Python tracker

[issue45563] inspect.getframeinfo() doesn't handle frames without lineno

2021-10-23 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Hmm, perhaps I should reopen the ticket, even though I now found the cause. After all, it is possible that lineno is None and inspect.getframeinfo() cannot handle it :-) And it may be worthwhile investigating why recreation of a code object using:

[issue45563] inspect.getframeinfo() doesn't handle frames without lineno

2021-10-22 Thread Marc-Andre Lemburg
Change by Marc-Andre Lemburg : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue45563] inspect.getframeinfo() doesn't handle frames without lineno

2021-10-22 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Turns out this was a bug in the freeze.py script I was using. I had added a bug work-around for the modulefinder module and even though it should work as advertised, it seems to be missing some code object attributes when recreating the objects which

[issue45563] inspect.getframeinfo() doesn't handle frames without lineno

2021-10-22 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: I've looked at how the importlib freeze logic works, compared to Tools/freeze/freeze.py. The only difference I can spot is that importlib uses C to build the C array and does a compile followed by a marshal.dumps, whereas freeze.py loads all modules

[issue45563] inspect.getframeinfo() doesn't handle frames without lineno

2021-10-22 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: I see this in modules frozen by the Tools/freeze/ tool. The line numbers shown for such frozen modules in the frameinfo stack are a bit off as well, compared normal Python. Could this be an indication that there's something not working quite right,

[issue45563] inspect.getframeinfo() doesn't handle frames without lineno

2021-10-22 Thread Mark Shannon
Mark Shannon added the comment: If I knew where to look, I would be looking myself :) Is the frozen module one built into CPython or one you have generated? -- ___ Python tracker

[issue45563] inspect.getframeinfo() doesn't handle frames without lineno

2021-10-22 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Update: I've been trying hard to find a short version which triggers the issue, but so far it seems to only trigger when using exec() from a frozen Python module. There don't appear to be many ways frame->f_lineno can end up being -1 (which then gets

[issue45563] inspect.getframeinfo() doesn't handle frames without lineno

2021-10-22 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: In the case of setuptools, this would be the file setup.py, but I think the specific file is not relevant. I can try to come up with a shorter example. -- ___ Python tracker

[issue45563] inspect.getframeinfo() doesn't handle frames without lineno

2021-10-22 Thread Mark Shannon
Mark Shannon added the comment: What is `source`? -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45563] inspect.getframeinfo() doesn't handle frames without lineno

2021-10-22 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: To add some more context: This came up while porting eGenix PyRun to Python 3.10. While installing setuptools 58.2.0 via "pyrun setup.py install", an exception was raised in getframeinfo(). PyRun uses exec() to run Python code: def

[issue45563] inspect.getframeinfo() doesn't handle frames without lineno

2021-10-21 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- components: -Parser ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45563] inspect.getframeinfo() doesn't handle frames without lineno

2021-10-21 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- nosy: +Mark.Shannon ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45563] inspect.getframeinfo() doesn't handle frames without lineno

2021-10-21 Thread Marc-Andre Lemburg
Change by Marc-Andre Lemburg : -- components: +Interpreter Core, Library (Lib), Parser nosy: +lys.nikolaou, pablogsal ___ Python tracker ___

[issue45563] inspect.getframeinfo() doesn't handle frames without lineno

2021-10-21 Thread Marc-Andre Lemburg
New submission from Marc-Andre Lemburg : In Python 3.10, it seems that top-level frames generated by running exec() have their f_lineno attribute set to None. inspect.getframeinfo() tries to build context lines and fails on this line in such a case: start = lineno - 1 - context//2