Skip to content

Commit 354394d

Browse files
committed
Python: Don't use fake locations in diagnostics
Some of the internal tooling would not be too happy about this :D
1 parent 60d1dc8 commit 354394d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

python/extractor/semmle/logging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def syntax_error_message(exception, unit):
374374

375375
def recursion_error_message(exception, unit):
376376
# if unit is a BuiltinModuleExtractable, there will be no path attribute
377-
l = Location(file=getattr(unit, "path", str(unit)))
377+
l = Location(file=unit.path) if hasattr(unit, "path") else None
378378
return (DiagnosticMessage(Source("py/diagnostics/recursion-error", "Recursion error in Python extractor"), Severity.ERROR)
379379
.with_location(l)
380380
.text(exception.args[0])
@@ -385,7 +385,7 @@ def recursion_error_message(exception, unit):
385385

386386
def internal_error_message(exception, unit):
387387
# if unit is a BuiltinModuleExtractable, there will be no path attribute
388-
l = Location(file=getattr(unit, "path", str(unit)))
388+
l = Location(file=unit.path) if hasattr(unit, "path") else None
389389
return (DiagnosticMessage(Source("py/diagnostics/internal-error", "Internal error in Python extractor"), Severity.ERROR)
390390
.with_location(l)
391391
.text("Internal error")

0 commit comments

Comments
 (0)