You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Over in ipython/ipykernel#1072, we noticed that sometimes getting the variables in a frame lists a function starting with a underscore as a normal variable, instead of grouping it with the function variables.
Here's a self-contained example illustrating the issue if run in ipython.
Install ipython and debugpy: pip install ipython debugpy
Create the repro.py file below:
repro.py
# This is example reproduces code from https://github.com/ipython/ipykernel/blob/main/ipykernel/debugger.py# This import is required to have the next ones working...fromdebugpy.serverimportapi# noqafrom_pydevd_bundleimportpydevd_frame_utils# isort: skipfrom_pydevd_bundle.pydevd_suspended_framesimport ( # isort: skipSuspendedFramesManager,
_FramesTracker,
)
class_FakeCode:
def__init__(self, co_filename, co_name):
self.co_filename=co_filenameself.co_name=co_nameclass_FakeFrame:
def__init__(self, f_code, f_globals, f_locals):
self.f_code=f_codeself.f_globals=f_globalsself.f_locals=f_localsself.f_back=Noneclass_DummyPyDB:
def__init__(self):
from_pydevd_bundle.pydevd_apiimportPyDevdAPIself.variable_presentation=PyDevdAPI.VariablePresentation()
classVariableExplorer:
def__init__(self):
self.suspended_frame_manager=SuspendedFramesManager()
self.py_db=_DummyPyDB()
self.tracker=_FramesTracker(self.suspended_frame_manager, self.py_db)
self.frame=Nonedeftrack(self):
var=get_ipython().user_nsself.frame=_FakeFrame(_FakeCode("<module>", 'filename'), var, var)
self.tracker.track("thread1", pydevd_frame_utils.create_frames_list_from_frame(self.frame))
defuntrack_all(self):
self.tracker.untrack_all()
defget_children_variables(self, variable_ref=None):
var_ref=variable_refifnotvar_ref:
var_ref=id(self.frame)
variables=self.suspended_frame_manager.get_variable(var_ref)
return [x.get_var_data() forxinvariables.get_children_variables()]
# Create a variable explorerv=VariableExplorer()
v.track()
# Define two functions, one starting with an underscoredefabc():
...
def_abc():
...
# Note that `abc` does not appear in the results, but `_abc` does appear in the results.importpprintpprint.pprint([vforvinv.get_children_variables() if'abc'inv["name"]])
Run ipython repro.py. Notice that _abc is listed in the output, but abc is not listed in the output.
My confusion is: it appears that abc is grouped with function variables, which is why it doesn't appear in the output. Why is _abc not grouped with the function variables, i.e., why does it appear in the output?
The text was updated successfully, but these errors were encountered:
Over in ipython/ipykernel#1072, we noticed that sometimes getting the variables in a frame lists a function starting with a underscore as a normal variable, instead of grouping it with the function variables.
Here's a self-contained example illustrating the issue if run in ipython.
ipython
anddebugpy
:pip install ipython debugpy
repro.py
file below:repro.py
ipython repro.py
. Notice that_abc
is listed in the output, butabc
is not listed in the output.My confusion is: it appears that
abc
is grouped with function variables, which is why it doesn't appear in the output. Why is_abc
not grouped with the function variables, i.e., why does it appear in the output?The text was updated successfully, but these errors were encountered: