Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

test_walk_above_recursion_limit uses absolute limits #116057

Closed
Labels
type-bugAn unexpected behavior, bug, or error
@mhsmith

Description

@mhsmith

Bug report

Bug description:

os.walk andPath.walk both have a test verifying that they're not implemented recursively. However, their recursion limits are absolute rather than relative to the current frame. Since the test framework itself already consumes about 30 frames, it only takes a few extra frames to cause a spurious failure. This can easily happen when running the tests within another script, which happens in the Android testbed.

For example, if the limit in test_pathlib is reduced from 40 to 35:

======================================================================ERROR: test_walk_above_recursion_limit (test.test_pathlib.test_pathlib.PosixPathTest.test_walk_above_recursion_limit)----------------------------------------------------------------------Traceback (most recent call last):  File "/Users/msmith/git/python/cpython/Lib/pathlib/__init__.py", line 241, in __str__    return self._str           ^^^^^^^^^AttributeError: 'PosixPath' object has no attribute '_str'During handling of the above exception, another exception occurred:Traceback (most recent call last):  File "/Users/msmith/git/python/cpython/Lib/pathlib/__init__.py", line 300, in drive    return self._drv           ^^^^^^^^^AttributeError: 'PosixPath' object has no attribute '_drv'During handling of the above exception, another exception occurred:Traceback (most recent call last):  File "/Users/msmith/git/python/cpython/Lib/test/test_pathlib/test_pathlib.py", line 1203, in test_walk_above_recursion_limit    list(base.walk())    ~~~~^^^^^^^^^^^^^  File "/Users/msmith/git/python/cpython/Lib/pathlib/_abc.py", line 875, in walk    scandir_obj = path._scandir()                  ~~~~~~~~~~~~~^^  File "/Users/msmith/git/python/cpython/Lib/pathlib/__init__.py", line 588, in _scandir    return os.scandir(self)           ~~~~~~~~~~^^^^^^  File "/Users/msmith/git/python/cpython/Lib/pathlib/__init__.py", line 177, in __fspath__    return str(self)           ~~~^^^^^^  File "/Users/msmith/git/python/cpython/Lib/pathlib/__init__.py", line 243, in __str__    self._str = self._format_parsed_parts(self.drive, self.root,                                          ^^^^^^^^^^  File "/Users/msmith/git/python/cpython/Lib/pathlib/__init__.py", line 302, in drive    self._drv, self._root, self._tail_cached = self._parse_path(self._raw_path)                                                                ^^^^^^^^^^^^^^  File "/Users/msmith/git/python/cpython/Lib/pathlib/__init__.py", line 293, in _raw_path    path = self.pathmod.join(*paths)           ~~~~~~~~~~~~~~~~~^^^^^^^^  File "<frozen posixpath>", line 77, in joinRecursionError: maximum recursion depth exceeded

CPython versions tested on:

CPython main branch

Operating systems tested on:

  • macOS
  • Android

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp