Skip to content

Commit d39b4f2

Browse files
restrict shape in variable loading
1 parent a215b5d commit d39b4f2

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

news/2 Fixes/5387.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Value 'None' sometimes shows up in the Count column of the variable explorer

pythonFiles/datascience/getJupyterVariableValue.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
# Find shape and count if available
1111
if (hasattr(_VSCODE_evalResult, 'shape')):
1212
try:
13-
_VSCODE_targetVariable['shape'] = str(_VSCODE_evalResult.shape)
13+
# Get a bit more restrictive with exactly what we want to count as a shape, since anything can define it
14+
if isinstance(_VSCODE_evalResult.shape, tuple):
15+
_VSCODE_shapeStr = str(_VSCODE_evalResult.shape)
16+
if len(_VSCODE_shapeStr) >= 3 and _VSCODE_shapeStr[0] == '(' and _VSCODE_shapeStr[-1] == ')' and ',' in _VSCODE_shapeStr:
17+
_VSCODE_targetVariable['shape'] = _VSCODE_shapeStr
18+
del _VSCODE_shapeStr
1419
except TypeError:
1520
pass
1621

0 commit comments

Comments
 (0)