FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

util: fix .format() not always calling toString when it should be by BridgeAR · Pull Request #30343 · nodejs/node · GitHub

/ node Public

util: fix .format() not always calling toString when it should be - #30343

Closed
BridgeAR wants to merge 2 commits into
nodejs:masterfrom
BridgeAR:fix-to-string-subclassing
Closed

util: fix .format() not always calling toString when it should be#30343
BridgeAR wants to merge 2 commits into
nodejs:masterfrom
BridgeAR:fix-to-string-subclassing

Conversation

BridgeAR commented Nov 9, 2019
edited
Loading

Copy link
Copy Markdown
Member

This makes sure that util.format('%s', object) will always call
a user defined toString function. It was formerly not the case
when the object had the function declared on the super class.

At the same time this also makes sure that getters won't be
triggered accessing the constructor property.

Fixes: #30333

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

nodejs-github-bot added the util Issues and PRs related to the built-in util module. label Nov 9, 2019

This comment has been minimized.

BridgeAR added the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Nov 12, 2019
Comment thread lib/internal/util/inspect.js Outdated

lundibundi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM, 👍

Comment thread lib/internal/util/inspect.js Outdated

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This makes sure that `util.format('%s', object)` will always call
a user defined `toString` function. It was formerly not the case
when the object had the function declared on the super class.

At the same time this also makes sure that getters won't be
triggered accessing the `constructor` property.
BridgeAR force-pushed the fix-to-string-subclassing branch from 96dee25 to cde7fde Compare November 26, 2019 16:32

This comment has been minimized.

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Collaborator

addaleax pushed a commit that referenced this pull request Nov 30, 2019
This makes sure that `util.format('%s', object)` will always call
a user defined `toString` function. It was formerly not the case
when the object had the function declared on the super class.

At the same time this also makes sure that getters won't be
triggered accessing the `constructor` property.

PR-URL: #30343
Fixes: #30333
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>

Copy link
Copy Markdown
Member

Landed in be30911

addaleax closed this Nov 30, 2019
targos pushed a commit that referenced this pull request Dec 1, 2019
This makes sure that `util.format('%s', object)` will always call
a user defined `toString` function. It was formerly not the case
when the object had the function declared on the super class.

At the same time this also makes sure that getters won't be
triggered accessing the `constructor` property.

PR-URL: #30343
Fixes: #30333
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
BridgeAR mentioned this pull request Dec 3, 2019

targos commented Jan 14, 2020

Copy link
Copy Markdown
Member

Should this be backported to v12.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

MylesBorins pushed a commit that referenced this pull request Jan 30, 2020
This makes sure that `util.format('%s', object)` will always call
a user defined `toString` function. It was formerly not the case
when the object had the function declared on the super class.

At the same time this also makes sure that getters won't be
triggered accessing the `constructor` property.

Backport-PR-URL: #31431
PR-URL: #30343
Fixes: #30333
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
BethGriggs pushed a commit that referenced this pull request Feb 6, 2020
This makes sure that `util.format('%s', object)` will always call
a user defined `toString` function. It was formerly not the case
when the object had the function declared on the super class.

At the same time this also makes sure that getters won't be
triggered accessing the `constructor` property.

Backport-PR-URL: #31431
PR-URL: #30343
Fixes: #30333
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
MylesBorins mentioned this pull request Feb 8, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. util Issues and PRs related to the built-in util module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

util.format('%s', o) fails to call String(o) in certain cases

8 participants


Back | FazBrowse Home | New Git URL