Python: Handle diagnostics writing for BuiltinModuleExtractable

This commit is contained in:
Rasmus Wriedt Larsen
2024-07-09 13:55:28 +02:00
parent c1da2c1d2f
commit 6b3625e24e

View File

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