Skip to content

Commit c052767

Browse files
authored
Python: When failing to take a snapshot, also log constructor name of value (#5518)
1 parent dcf45a9 commit c052767

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/pyodide/internal/snapshot.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,14 @@ function describeValue(val: any): string {
485485
const isObject = type === 'object';
486486
out.push(`Value: ${val}`);
487487
out.push(`Type: ${type}`);
488+
try {
489+
const constructorName = val?.constructor?.name; // eslint-disable-line
490+
if (constructorName) {
491+
out.push(`Constructor name: ${constructorName}`);
492+
}
493+
} catch {
494+
// Ignore errors when getting keys
495+
}
488496

489497
if (val && isObject) {
490498
try {
@@ -507,7 +515,7 @@ function describeValue(val: any): string {
507515
}
508516

509517
try {
510-
out.push(`Prototype: ${Object.prototype.toString.call(val)}`);
518+
out.push(`toStringTag: ${Object.prototype.toString.call(val)}`);
511519
} catch {
512520
// Ignore errors when getting object type
513521
}

0 commit comments

Comments
 (0)