"Server[1] disconnected unexpectedly" when inspecting python-pptx XML element in VS Code
bersbersbers opened this issue · 2 comments
Environment data
- PTVSD version: old (4.x) or new (5.x) as bundled in VS Code 1.42.0/VS Code Python 2020.3.62694-dev
- OS and version: Windows 10 1909
- Python version (& distribution if applicable, e.g. Anaconda): Plain 3.8.1
- Using VS Code or Visual Studio: VS Code
Actual behavior
I am not sure this is PTVSD's issue, or VSCode-Python's, or VS Code's, pyhton-pptx', or even Python's. But I have to start somewhere, and my naive assumption is that PTVSD should catch any crashed while inspecting variables.
Anyway, upon debugging below code, issuing "el" correctly yields
el
> <Element {http://schemas.openxmlformats.org/presentationml/2006/main}ph at 0x223bd3a53b0>
in the Debug Console. Clicking >
to expand the element leads to a crash (Method 1) or an infinitely rotating throbber (Method 2). This is the output for the crash:
: Server[1] disconnected unexpectedly
Traceback (most recent call last):
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_frame.py", line 712, in trace_dispatch
self.do_wait_suspend(thread, frame, event, arg)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_frame.py", line 89, in do_wait_suspend
self._args[0].do_wait_suspend(*args, **kwargs)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\pydevd.py", line 1772, in do_wait_suspend
keep_suspended = self._do_wait_suspend(thread, frame, event, arg, suspend_type, from_this_thread, frames_tracker)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\pydevd.py", line 1803, in _do_wait_suspend
self.process_internal_commands()
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\pydevd.py", line 1492, in process_internal_commands
int_cmd.do_it(self)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 549, in do_it
self.method(dbg, *self.args, **self.kwargs)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 722, in internal_get_variable_json
for child_var in variable.get_children_variables(fmt=fmt):
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_suspended_frames.py", line 112, in get_children_variables
lst = resolver.get_contents_debug_adapter_protocol(self.value, fmt=fmt)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_resolver.py", line 95, in get_contents_debug_adapter_protocol
dct, used___dict__ = self._get_py_dictionary(obj)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_resolver.py", line 192, in _get_py_dictionary
names, used___dict__ = self.get_names(var)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_resolver.py", line 174, in get_names
if hasattr(var, '__dict__'):
TypeError: descriptor '__dict__' for '_OxmlElementBase' objects doesn't apply to a 'CT_Placeholder' object
Traceback (most recent call last):
File "C:\Users\bers\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\bers\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\__main__.py", line 45, in <module>
cli.main()
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd/..\ptvsd\server\cli.py", line 361, in main
run()
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd/..\ptvsd\server\cli.py", line 203, in run_file
runpy.run_path(options.target, run_name="__main__")
File "C:\Users\bers\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 263, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Users\bers\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\bers\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\Work\bug.py", line 8, in <module>
pass # Method 1: set a manual breakpoint here; leads to crash
File "c:\Work\bug.py", line 8, in <module>
pass # Method 1: set a manual breakpoint here; leads to crash
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_frame.py", line 712, in trace_dispatch
self.do_wait_suspend(thread, frame, event, arg)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_frame.py", line 89, in do_wait_suspend
self._args[0].do_wait_suspend(*args, **kwargs)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\pydevd.py", line 1772, in do_wait_suspend
keep_suspended = self._do_wait_suspend(thread, frame, event, arg, suspend_type, from_this_thread, frames_tracker)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\pydevd.py", line 1803, in _do_wait_suspend
self.process_internal_commands()
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\pydevd.py", line 1492, in process_internal_commands
int_cmd.do_it(self)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 549, in do_it
self.method(dbg, *self.args, **self.kwargs)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 722, in internal_get_variable_json
for child_var in variable.get_children_variables(fmt=fmt):
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_suspended_frames.py", line 112, in get_children_variables
lst = resolver.get_contents_debug_adapter_protocol(self.value, fmt=fmt)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_resolver.py", line 95, in get_contents_debug_adapter_protocol
dct, used___dict__ = self._get_py_dictionary(obj)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_resolver.py", line 192, in _get_py_dictionary
names, used___dict__ = self.get_names(var)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\new_ptvsd\no_wheels\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_resolver.py", line 174, in get_names
if hasattr(var, '__dict__'):
TypeError: descriptor '__dict__' for '_OxmlElementBase' objects doesn't apply to a 'CT_Placeholder' object
Expected behavior
The element should be expanded as much as possible, catching exceptions along the way.
Steps to reproduce:
This is my launch configuration:
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"internalConsoleOptions": "openOnSessionStart",
"console": "internalConsole",
"justMyCode": false,
},
And this my code. Note there's two way to set a breakpoint, with different results. In both cases, upon hitting the breakpoint, issue el
in the Debug Console, then click >
to expand the result.
"""Setup: pip install python-pptx."""
import pptx
el = pptx.Presentation().slide_layouts[0].placeholders[0].placeholder_format._element
# breakpoint() # Method 2: enable breakpoint() here; leads to infinite(?) throbber
pass # Method 1: set a manual breakpoint here; leads to crash
# Repro bug by issuing "el" in Debug Console and expand the result
And here's the crash output with the old PTVSD:
: Canceled
Traceback (most recent call last):
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\ptvsd_launcher.py", line 48, in <module>
main(ptvsdArgs)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\old_ptvsd\ptvsd\__main__.py", line 432, in main
run()
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\old_ptvsd\ptvsd\__main__.py", line 316, in run_file
runpy.run_path(target, run_name='__main__')
File "C:\Users\bers\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 263, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Users\bers\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\bers\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\Work\bug.py", line 8, in <module>
pass # Method 1: set a manual breakpoint here; leads to crash
File "c:\Work\bug.py", line 8, in <module>
pass # Method 1: set a manual breakpoint here; leads to crash
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\old_ptvsd\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_frame.py", line 606, in trace_dispatch
self.do_wait_suspend(thread, frame, event, arg)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\old_ptvsd\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_frame.py", line 97, in do_wait_suspend
self._args[0].do_wait_suspend(*args, **kwargs)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\old_ptvsd\ptvsd\_vendored\pydevd\pydevd.py", line 1616, in do_wait_suspend
keep_suspended = self._do_wait_suspend(thread, frame, event, arg, suspend_type, from_this_thread, frames_tracker)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\old_ptvsd\ptvsd\_vendored\pydevd\pydevd.py", line 1644, in _do_wait_suspend
self.process_internal_commands()
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\old_ptvsd\ptvsd\_vendored\pydevd\pydevd.py", line 1350, in process_internal_commands
int_cmd.do_it(self)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\old_ptvsd\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 502, in do_it
self.method(dbg, *self.args, **self.kwargs)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\old_ptvsd\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 675, in internal_get_variable_json
for child_var in variable.get_children_variables(fmt=fmt):
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\old_ptvsd\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_suspended_frames.py", line 111, in get_children_variables
lst = resolver.get_contents_debug_adapter_protocol(self.value, fmt=fmt)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\old_ptvsd\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_resolver.py", line 95, in get_contents_debug_adapter_protocol
dct, used___dict__ = self._get_py_dictionary(obj)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\old_ptvsd\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_resolver.py", line 192, in _get_py_dictionary
names, used___dict__ = self.get_names(var)
File "c:\Users\bers\.vscode\extensions\ms-python.python-2020.3.62694-dev\pythonFiles\lib\python\old_ptvsd\ptvsd\_vendored\pydevd\_pydevd_bundle\pydevd_resolver.py", line 174, in get_names
if hasattr(var, '__dict__'):
TypeError: descriptor '__dict__' for '_OxmlElementBase' objects doesn't apply to a 'CT_Placeholder' object