Skip to content

Commit 5f8c4b2

Browse files
author
Pavel Minaev
committed
Fix microsoft#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 3da94f3 commit 5f8c4b2

File tree

6 files changed

+96
-3
lines changed

6 files changed

+96
-3
lines changed

Diff for: setup.py

+8-1
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": [
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import pkgutil
2+
__path__ = pkgutil.extend_path(__path__, __name__)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import pkgutil
2+
__path__ = pkgutil.extend_path(__path__, __name__)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import pkgutil
2+
__path__ = pkgutil.extend_path(__path__, __name__)

Diff for: tests/debugpy/test_numpy.py

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

Diff for: tests/requirements.txt

+3-2
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)