mirror of
https://github.com/python/cpython.git
synced 2025-10-15 03:10:29 +00:00
gh-125084: Resolve paths in generator common code (GH-125085)
In out of tree builds, the paths can contain `../ which needs to be resolved for the relative path calculation to work.
This commit is contained in:
parent
fca552993d
commit
7dca7322cc
1 changed files with 3 additions and 3 deletions
|
@ -43,13 +43,13 @@ class TokenIterator:
|
||||||
break
|
break
|
||||||
return self.look_ahead
|
return self.look_ahead
|
||||||
|
|
||||||
ROOT = Path(__file__).parent.parent.parent
|
ROOT = Path(__file__).parent.parent.parent.resolve()
|
||||||
DEFAULT_INPUT = (ROOT / "Python/bytecodes.c").absolute().as_posix()
|
DEFAULT_INPUT = (ROOT / "Python/bytecodes.c").as_posix()
|
||||||
|
|
||||||
|
|
||||||
def root_relative_path(filename: str) -> str:
|
def root_relative_path(filename: str) -> str:
|
||||||
try:
|
try:
|
||||||
return Path(filename).absolute().relative_to(ROOT).as_posix()
|
return Path(filename).resolve().relative_to(ROOT).as_posix()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# Not relative to root, just return original path.
|
# Not relative to root, just return original path.
|
||||||
return filename
|
return filename
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue