From 7d5c55fa2e070336d7ce53247af2e41feb4f78e7 Mon Sep 17 00:00:00 2001 From: Fabio Zadrozny Date: Wed, 1 Apr 2020 10:25:43 -0300 Subject: [PATCH] Synchronizing with contributed changes to pydevd. --- .../pydevd/_pydev_runfiles/pydev_runfiles_pytest2.py | 10 +++++++++- .../_vendored/pydevd/_pydevd_bundle/pydevd_utils.py | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_pytest2.py b/src/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_pytest2.py index 971491b9..3692eb72 100644 --- a/src/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_pytest2.py +++ b/src/debugpy/_vendored/pydevd/_pydev_runfiles/pydev_runfiles_pytest2.py @@ -151,7 +151,15 @@ def pytest_collection_modifyitems(session, config, items): pydev_runfiles_xml_rpc.notifyTestsCollected(len(items)) -from py.io import TerminalWriter +try: + """ + pytest > 5.4 uses own version of TerminalWriter based on py.io.TerminalWriter + and assumes there is a specific method TerminalWriter._write_source + so try load pytest version first or fallback to default one + """ + from _pytest._io import TerminalWriter +except ImportError: + from py.io import TerminalWriter def _get_error_contents_from_report(report): diff --git a/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_utils.py b/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_utils.py index 2fbd416b..691fd970 100644 --- a/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_utils.py +++ b/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_utils.py @@ -134,7 +134,10 @@ def get_clsname_for_code(code, frame): if inspect.isclass(first_arg_obj): # class method first_arg_class = first_arg_obj else: # instance method - first_arg_class = first_arg_obj.__class__ + if hasattr(first_arg_obj, "__class__"): + first_arg_class = first_arg_obj.__class__ + else: # old style class, fall back on type + first_arg_class = type(first_arg_obj) func_name = code.co_name if hasattr(first_arg_class, func_name): method = getattr(first_arg_class, func_name)