Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Closed as duplicate
Description
os.path.realpath()
attempts to detect symlink loops, but this is not bulletproof;
it's possible to make it fall into infinite recursion.
Reproducer:
importosimporttempfilewithtempfile.TemporaryDirectory()astmpdir:os.chdir(tmpdir)os.symlink('../'* (1+tmpdir.count('/'))+f'{tmpdir}/d','d')os.path.realpath('d')
Traceback:
Traceback (most recent call last): File".../recursiverealpath.py", line7, in<module> os.path.realpath('d') File"<frozen posixpath>", line427, inrealpath File"<frozen posixpath>", line487, in_joinrealpath File"<frozen posixpath>", line487, in_joinrealpath File"<frozen posixpath>", line487, in_joinrealpath [Previous line repeated 993 more times] File"<frozen posixpath>", line442, in_joinrealpath File"<frozen posixpath>", line63, inisabsRecursionError:maximum recursion depth exceeded
Tested with Python 3.12.8.