Skip to content

Commit

Permalink
pythongh-125084: Resolve paths in generator common code (pythonGH-125085
Browse files Browse the repository at this point in the history
)

In out of tree builds, the paths can contain `../ which needs to be
resolved for the relative path calculation to work.
  • Loading branch information
cmaloney authored and efimov-mikhail committed Oct 9, 2024
1 parent bd716e0 commit b2764a9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Tools/cases_generator/generators_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ def peek(self) -> Token | None:
break
return self.look_ahead

ROOT = Path(__file__).parent.parent.parent
DEFAULT_INPUT = (ROOT / "Python/bytecodes.c").absolute().as_posix()
ROOT = Path(__file__).parent.parent.parent.resolve()
DEFAULT_INPUT = (ROOT / "Python/bytecodes.c").as_posix()


def root_relative_path(filename: str) -> str:
try:
return Path(filename).absolute().relative_to(ROOT).as_posix()
return Path(filename).resolve().relative_to(ROOT).as_posix()
except ValueError:
# Not relative to root, just return original path.
return filename
Expand Down

0 comments on commit b2764a9

Please sign in to comment.