Skip to content

Commit b9b09e6

Browse files
Pavel Minaevint19h
authored andcommitted
Fix #1408: Can no longer expand Numpy arrays to view elements
Fix regression when loading pydevd plugins for numpy, pandas, and django. Add smoke test for numpy arrays.
1 parent e9a39f7 commit b9b09e6

File tree

6 files changed

+94
-3
lines changed

6 files changed

+94
-3
lines changed

setup.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,14 @@ def tail_is(*suffixes):
176176
"License :: OSI Approved :: MIT License",
177177
],
178178
package_dir={"": "src"},
179-
packages=setuptools.find_namespace_packages(where="src", include=["debugpy*"]),
179+
packages=[
180+
"debugpy",
181+
"debugpy.adapter",
182+
"debugpy.common",
183+
"debugpy.launcher",
184+
"debugpy.server",
185+
"debugpy._vendored",
186+
],
180187
package_data={
181188
"debugpy": ["ThirdPartyNotices.txt"],
182189
"debugpy._vendored": [
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import pkgutil
2+
__path__ = pkgutil.extend_path(__path__, __name__)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import pkgutil
2+
__path__ = pkgutil.extend_path(__path__, __name__)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import pkgutil
2+
__path__ = pkgutil.extend_path(__path__, __name__)

tests/debugpy/test_numpy.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License. See LICENSE in the project root
3+
# for license information.
4+
5+
from tests import debug
6+
from tests.patterns import some
7+
8+
9+
def test_ndarray(pyfile, target, run):
10+
@pyfile
11+
def code_to_debug():
12+
import numpy
13+
import debuggee
14+
15+
debuggee.setup()
16+
a = numpy.array([123, 456], numpy.int32)
17+
print(a) # @bp
18+
19+
with debug.Session() as session:
20+
session.config["variablePresentation"] = {"all": "hide", "protected": "inline"}
21+
with run(session, target(code_to_debug)):
22+
session.set_breakpoints(code_to_debug, all)
23+
24+
stop = session.wait_for_stop()
25+
scopes = session.request("scopes", {"frameId": stop.frame_id})["scopes"]
26+
globals_ref = scopes[0]["variablesReference"]
27+
vars = session.request(
28+
"variables",
29+
{"variablesReference": globals_ref},
30+
)["variables"]
31+
print(vars)
32+
33+
# Fetch children variables of the array.
34+
(a,) = (v for v in vars if v["name"] == "a")
35+
a_vars = session.request(
36+
"variables",
37+
{"variablesReference": a["variablesReference"]},
38+
)["variables"]
39+
print(a_vars)
40+
41+
# Fetch the actual array items
42+
(items,) = (v for v in a_vars if v["name"] == "[0:2] ")
43+
a_items = session.request(
44+
"variables",
45+
{"variablesReference": items["variablesReference"]},
46+
)["variables"]
47+
print(a_items)
48+
49+
assert a_items == [
50+
some.dict.containing(
51+
{
52+
"type": "int32",
53+
"name": "0",
54+
"value": "123",
55+
"variablesReference": some.int,
56+
}
57+
),
58+
some.dict.containing(
59+
{
60+
"type": "int32",
61+
"name": "1",
62+
"value": "456",
63+
"variablesReference": some.int,
64+
}
65+
),
66+
some.dict.containing(
67+
{
68+
"type": "int",
69+
"name": "len()",
70+
"value": "2",
71+
"presentationHint": {"attributes": ["readOnly"]},
72+
"variablesReference": 0,
73+
}
74+
),
75+
]
76+
77+
session.request_continue()

tests/requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ psutil
1313
## Used in Python code that is run/debugged by the tests:
1414

1515
django
16-
requests
17-
gevent
1816
flask
17+
gevent
18+
numpy
19+
requests

0 commit comments

Comments
 (0)