Commit a1ce776
util: fix .format() not always calling toString when it should be
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>1 parent ea3d4e8 commit a1ce776Copy full SHA for a1ce776
File tree
Expand file treeCollapse file tree
2 files changed
+94
-22
lines changedOpen diff view settings
Filter options
- lib/internal/util
- test/parallel
Expand file treeCollapse file tree
2 files changed
+94
-22
lines changedOpen diff view settings
Collapse file
lib/internal/util/inspect.js
Copy file name to clipboardExpand all lines: lib/internal/util/inspect.js+34-22Lines changed: 34 additions & 22 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1645 | 1645 | |
1646 | 1646 | |
1647 | 1647 | |
| 1648 | + |
| 1649 | + |
| 1650 | + |
| 1651 | + |
| 1652 | + |
| 1653 | + |
| 1654 | + |
| 1655 | + |
| 1656 | + |
| 1657 | + |
| 1658 | + |
| 1659 | + |
| 1660 | + |
| 1661 | + |
| 1662 | + |
| 1663 | + |
| 1664 | + |
| 1665 | + |
| 1666 | + |
| 1667 | + |
| 1668 | + |
| 1669 | + |
| 1670 | + |
| 1671 | + |
1648 | 1672 | |
1649 | 1673 | |
1650 | 1674 | |
| ||
1692 | 1716 | |
1693 | 1717 | |
1694 | 1718 | |
| 1719 | + |
| 1720 | + |
| 1721 | + |
| 1722 | + |
1695 | 1723 | |
1696 | | - |
1697 | | - |
1698 | | - |
1699 | | - |
1700 | | - |
1701 | | - |
1702 | | - |
1703 | | - |
1704 | | - |
1705 | | - |
1706 | | - |
1707 | | - |
1708 | | - |
1709 | | - |
1710 | | - |
1711 | | - |
1712 | | - |
1713 | | - |
1714 | | - |
1715 | | - |
1716 | | - |
1717 | | - |
| 1724 | + |
| 1725 | + |
| 1726 | + |
| 1727 | + |
| 1728 | + |
| 1729 | + |
1718 | 1730 | |
1719 | 1731 | |
1720 | 1732 | |
|
Collapse file
test/parallel/test-util-format.js
Copy file name to clipboardExpand all lines: test/parallel/test-util-format.js+60Lines changed: 60 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
160 | 160 | |
161 | 161 | |
162 | 162 | |
| 163 | + |
| 164 | + |
| 165 | + |
| 166 | + |
| 167 | + |
| 168 | + |
| 169 | + |
| 170 | + |
| 171 | + |
| 172 | + |
| 173 | + |
| 174 | + |
| 175 | + |
| 176 | + |
| 177 | + |
| 178 | + |
| 179 | + |
| 180 | + |
| 181 | + |
| 182 | + |
| 183 | + |
| 184 | + |
| 185 | + |
| 186 | + |
| 187 | + |
| 188 | + |
| 189 | + |
| 190 | + |
| 191 | + |
| 192 | + |
| 193 | + |
| 194 | + |
| 195 | + |
| 196 | + |
| 197 | + |
| 198 | + |
| 199 | + |
| 200 | + |
| 201 | + |
| 202 | + |
| 203 | + |
| 204 | + |
| 205 | + |
| 206 | + |
| 207 | + |
| 208 | + |
| 209 | + |
| 210 | + |
| 211 | + |
| 212 | + |
| 213 | + |
| 214 | + |
| 215 | + |
| 216 | + |
| 217 | + |
| 218 | + |
| 219 | + |
| 220 | + |
| 221 | + |
| 222 | + |
163 | 223 | |
164 | 224 | |
165 | 225 | |
|
0 commit comments