File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -366,11 +366,16 @@ def _get_source_root():
366366def _relative_path (path ):
367367 """Make a path relative to the source root for use in diagnostic locations.
368368 If the path is not under the source root, return it unchanged."""
369- source_root = _get_source_root ()
370- relpath = os .path .relpath (path , source_root )
369+ source_root = os .path .abspath (_get_source_root ())
370+ abs_path = os .path .abspath (path )
371+ try :
372+ relpath = os .path .relpath (abs_path , source_root )
373+ except ValueError :
374+ # On Windows, relpath raises ValueError for paths on different drives
375+ return path
371376 if relpath .startswith (os .pardir ):
372377 return path
373- return relpath
378+ return relpath . replace ( os . sep , "/" )
374379
375380def syntax_error_message (exception , unit ):
376381 diag_path = _relative_path (unit .path )
You can’t perform that action at this time.
0 commit comments