mirror of https://github.com/python/cpython
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
|
@ -43,13 +43,13 @@ class TokenIterator:
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue