Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Picked an invalid source context #71

Open
ale-dd opened this issue Mar 24, 2024 · 4 comments
Open

Picked an invalid source context #71

ale-dd opened this issue Mar 24, 2024 · 4 comments

Comments

@ale-dd
Copy link

ale-dd commented Mar 24, 2024

Ran into a "Picked an invalid source context".

I've only seen this once thus far. On python 3.12.0 with StackPrinter 0.2.12.

Stackprinter failed while formatting <FrameInfo xyz.py, line 2249, scope main>:
  File "venv312/lib/python3.12/site-packages/stackprinter/frame_formatting.py", line 225, in select_scope
    raise Exception("Picked an invalid source context: %s" % info)
Exception: Picked an invalid source context: [2249], [2233], dict_keys([2233, 2234, 2235, 2236, 2237, 2238, 2239])

So here is your original traceback at least:

Traceback (most recent call last):
...
KeyError: 0
@cknd
Copy link
Owner

cknd commented Mar 24, 2024

you're once again finding the best edge cases!
could you insert a pdb.set_trace() in site-packages/stackprinter/frame_formatting.py line 225 to check on which kind of inputs / source file it happens? (happy to use a private channel too)

@ale-dd
Copy link
Author

ale-dd commented Mar 24, 2024

The next time, everything worked as intended. This seems likely a lot harder to reproduce...

@ale-dd
Copy link
Author

ale-dd commented Mar 24, 2024

(I'll add the pdb hook, hoping to see this again)

@cknd
Copy link
Owner

cknd commented Mar 25, 2024

thanks!
could you place this extended piece of debug code in frame_formatting.py line 222? just to grab as much info as possible in the event it happens again

            if not set(source_lines).issubset(fi.source_map.keys()):
                debug_vals = [self.lines, lineno, source_lines, fi.head_lns, fi.source_map.keys(), fi]
                info = ', '.join(str(p) for p in debug_vals)
                raise Exception("Picked an invalid source context. Debug info: %r" % info)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants