8000 gh-89727: Fix pathlib.Path.walk RecursionError on deep trees by zmievsa · Pull Request #100282 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-89727: Fix pathlib.Path.walk RecursionError on deep trees #100282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test for recursion limit
  • Loading branch information
zmievsa committed Dec 16, 2022
commit fb5a4c7af1331a9f916032f6fa15779ec2cacc70
10 changes: 10 additions & 0 deletions Lib/test/test_pathlib.py
3998
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from unittest import mock

from test.support import import_helper
from test.support import infinite_recursion
from test.support import is_emscripten, is_wasi
from test.support import os_helper
from test.support.os_helper import TESTFN, FakePath
Expand Down Expand Up @@ -2766,6 +2767,15 @@ def test_walk_many_open_files(self):
self.assertEqual(next(it), expected)
path = path / 'd'

def test_walk_above_recursion_limit(self):
base = pathlib.Path(os_helper.TESTFN, 'deep')
path = pathlib.Path(base, *(['d']*50))
path.mkdir(parents=True)

with infinite_recursion(25):
list(base.walk())
list(base.walk(top_down=False))


class PathTest(_BasePathTest, unittest.TestCase):
cls = pathlib.Path
Expand Down
0