Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util.inspect different in vm #4080

Closed
jbr opened this issue Dec 1, 2015 · 3 comments
Closed

util.inspect different in vm #4080

jbr opened this issue Dec 1, 2015 · 3 comments
Labels
util Issues and PRs related to the built-in util module. vm Issues and PRs related to the vm subsystem.

Comments

@jbr
Copy link

jbr commented Dec 1, 2015

I'm not entirely sure if this is a bug or my misunderstanding, but I was surprised to discover that these two expressions have different values in the 5.1.0 node repl:

vm.runInNewContext("util.inspect({})", { util: util }) //=> 'Object {}'
util.inspect({}) //=> '{}'

or for standalone examples outside of the repl:

bash> node -pe "require('vm').runInNewContext('util.inspect({})', { util: require('util') })"
Object {}
bash> node -pe "require('util').inspect({})"
{}

Is this intended behavior? Is there a way to get the repl equivalent result from util.inspect in a vm without resorting to string replacement?

@jbr
Copy link
Author

jbr commented Dec 1, 2015

I'm happy to investigate and contribute a pr to fix this if it is in fact a bug

@jbr jbr changed the title util.inspect different in repl vs in vm util.inspect different in vm Dec 1, 2015
@mscdex mscdex added util Issues and PRs related to the built-in util module. vm Issues and PRs related to the vm subsystem. labels Dec 1, 2015
@mscdex
Copy link
Contributor

mscdex commented Dec 1, 2015

There is a PR (#3385) that fixes this already. It's my fault, I forgot it was still open. I will work on landing it soon.

@mscdex
Copy link
Contributor

mscdex commented Dec 1, 2015

Fixed in 82b8355.

@mscdex mscdex closed this as completed Dec 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
util Issues and PRs related to the built-in util module. vm Issues and PRs related to the vm subsystem.
Projects
None yet
Development

No branches or pull requests

2 participants