Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Variable value includes type #19

Closed
int19h opened this issue Jan 24, 2018 · 2 comments
Closed

Variable value includes type #19

int19h opened this issue Jan 24, 2018 · 2 comments
Assignees
Labels

Comments

@int19h
Copy link
Contributor

int19h commented Jan 24, 2018

This is a quirk of pydevd - when reporting the value of the variable, it includes type as part of the value. E.g. given x = 123, the value is reported as int: 123. These are displayed as is in PyDev, but for VSC and especially VS (which has a separate type column), we don't want the type - it's redundant, and gets in the way of editing variable value.

It looks like the format is uniform, so we can just drop the part before the colon.

@int19h int19h added the Bug label Jan 24, 2018
@int19h int19h self-assigned this Jan 24, 2018
@int19h
Copy link
Contributor Author

int19h commented Jan 24, 2018

It looks like strings are special-cased in that they're not quoted - x = 'foo\nbar' becomes str: foo\nbar!

@int19h
Copy link
Contributor Author

int19h commented Jan 24, 2018

Turns out that pydevd computes values via str, implicitly:

                value = '%s: %s' % (cName, v)

Hence why strings aren't quoted (but e.g. bytes are). This would present a problem for some other types as well, and would deviate from our existing behavior. What we really want is repr.

The good news is that pydevd provides a way to register a custom value representation provider (StrPresentationProvider). So we can just plug in our existing SafeRepr implementation directly.

@int19h int19h closed this as completed in 4692041 Feb 7, 2018
int19h added a commit that referenced this issue Feb 7, 2018
Fix #19: Variable value includes type
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant