-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix: When using Nuitka to package a project, an error occurred when reading the file: "KeyError: 'self'" #12923 #12926
base: main
Are you sure you want to change the base?
Conversation
…en reading the file: "KeyError: 'self'" mne-tools#12923
Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴 |
@@ -157,6 +157,9 @@ def __init__( | |||
"first_samples": np.array(first_samps), | |||
"last_samples": np.array(last_samps), | |||
} | |||
|
|||
__import__("inspect").currentframe().f_locals.update(locals()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than adding this to every module before calling super().__init__(...)
, is there any way this magic could live inside super.__init__(...)
itself instead? You mention:
[inspect] only populates the call stack information when an exception occurs
So in theory it should be possible to use inspect.currentframe().f_back
to get back to this level and do something there, maybe?
Also not sure why you do __import__("inspect")
rather than just import inspect
at the top of the file...?
is there a reference / explanation for this? I saw it mentioned in the nuitka issue thread but it's not immediately obvious to me from reading the docs for the
which I think is referring to the problem you encountered, but it would be nice to have that confirmed / have a fuller explanation of what is going wrong. |
Also a side note -- IIRC the In other words, maybe we don't want to try super hard to make this work in all cases? Like if we just set |
Fixes #12923
The reason the current code cannot correctly retrieve the calling parameters is that the
inspect
module does not store complete frame information for each normal call by default; it only populates the call stack information when an exception occurs. In other words, the frame information that this code relies on may not be complete, which could lead to the inability to retrieve the parameters.