Skip to content

Commit 6b3625e

Browse files
committed
Python: Handle diagnostics writing for BuiltinModuleExtractable
1 parent c1da2c1 commit 6b3625e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

python/extractor/semmle/logging.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ def syntax_error_message(exception, unit):
373373
return error
374374

375375
def recursion_error_message(exception, unit):
376-
l = Location(file=unit.path)
376+
# if unit is a BuiltinModuleExtractable, there will be no path attribute
377+
l = Location(file=getattr(unit, "path", str(unit)))
377378
return (DiagnosticMessage(Source("py/diagnostics/recursion-error", "Recursion error in Python extractor"), Severity.ERROR)
378379
.with_location(l)
379380
.text(exception.args[0])
@@ -383,7 +384,8 @@ def recursion_error_message(exception, unit):
383384
)
384385

385386
def internal_error_message(exception, unit):
386-
l = Location(file=unit.path)
387+
# if unit is a BuiltinModuleExtractable, there will be no path attribute
388+
l = Location(file=getattr(unit, "path", str(unit)))
387389
return (DiagnosticMessage(Source("py/diagnostics/internal-error", "Internal error in Python extractor"), Severity.ERROR)
388390
.with_location(l)
389391
.text("Internal error")

0 commit comments

Comments
 (0)