Skip to content

Commit 5a820f1

Browse files
Merge branch 'main' into caleb/fix/variadic
2 parents 3b7fb97 + 89afe29 commit 5a820f1

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

python/pythonmonkey/builtin_modules/console.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,14 @@ class Console
9898
const header = args.length > 0
9999
? `Trace: ${format(...args)}\n`
100100
: 'Trace\n';
101-
const stacks = new Error().stack
102-
.split('\n')
103-
.filter(s => s !== '') // filter out empty lines
104-
.map(s => ' '+s) // add indent
105-
.join('\n');
101+
102+
let stacks = new Error().stack
103+
.split('\n')
104+
stacks.shift(); // skip the first line which is this.trace itself
105+
stacks = stacks
106+
.filter(s => s !== '') // filter out empty lines
107+
.map(s => ' '+s) // add indent
108+
.join('\n');
106109
return this.debug(header + stacks);
107110
};
108111

tests/js/console-methods.simple

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ expectOutput('stderr', /^Assertion failed: abc undefined$/m, (console) => consol
7373
expectOutput('stdout', /^Trace\n/, (console) => console.trace());
7474
expectOutput('stdout', /^Trace: \x1b\[90mundefined\x1b\[39m\n/, (console) => console.trace(undefined));
7575
expectOutput('stdout', /^Trace: \x1b\[33m123\x1b\[39m\n/, (console) => console.trace(123));
76+
expectOutput('stdout', /^((?!console\.js)[\s\S])*$/, (console) => console.trace()); // implementation details should not show up in the trace
7677

7778
// console.count()
7879
let keptConsole;

0 commit comments

Comments
 (0)