Closed as not planned
Description
Bug report
Bug description:
The strict argument in of pathlib.resolve() raises an unexpected exception where it should not and did not before in python 3.12 when using python 3.13.1. (Using the current build from debian-testing.
The issue is then
Traceback (most recent call last):
File "foo.py", line 2, in <module>
pathlib.Path(__file__, "../testpath").resolve(strict=True)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/usr/lib/python3.13/pathlib/_local.py", line 672, in resolve
return self.with_segments(os.path.realpath(self, strict=strict))
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File "<frozen posixpath>", line 448, in realpath
How to reproduce the error
import pathlib
import subprocess
import sys
pathlib.Path("testpath").mkdir(exist_ok=True)
pathlib.Path("test.py").write_text(
"""
import pathlib
pathlib.Path(__file__, "../testpath").resolve(strict=True)
""",
encoding="utf-8",
)
result = subprocess.run([sys.executable, "test.py"], check=False, capture_output=True)
print(result.stderr)
print(result.stdout)
assert result.returncode == 0
The call pathlib.Path(__file__, "../testpath").resolve(strict=True)
actually fails. What surprisingly does not fail in python 3.13.1 is pathlib.Path(__file__, "../testpath").resolve().resolve(strict=True)
CPython versions tested on:
3.13
Operating systems tested on:
Linux