GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `test_walk_above_recursion_limit` uses absolute limits · Issue #116057 · python/cpython

test_walk_above_recursion_limit uses absolute limits #116057

New issue
Copy link
New issue
Copy link
Closed
#116058
Closed
test_walk_above_recursion_limit uses absolute limits#116057
#116058
Copy link
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@mhsmith
mhsmith
opened on Feb 28, 2024
Issue body actions

Bug report

Bug description:

os.walk and Path.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 join
RecursionError: maximum recursion depth exceeded

CPython versions tested on:

CPython main branch

Operating systems tested on:

  • macOS
  • Android

Linked PRs

  • gh-116057: Use relative recursion limits when testing os.walk and Path.walk #116058

Activity

  1. mhsmith
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Feb 28, 2024
  2. erlend-aasland
    closed this as completedin #116058on Mar 10, 2024
  3. erlend-aasland
    added a commit that references this issue on Mar 10, 2024

    gh-116057: Use relative recursion limits when testing os.walk() and P…

    2339e7c
  4. adorilson
    added a commit that references this issue on Mar 25, 2024

    pythongh-116057: Use relative recursion limits when testing os.walk()…

    dda16bb
  5. diegorusso
    added a commit that references this issue on Apr 17, 2024

    pythongh-116057: Use relative recursion limits when testing os.walk()…

    4c98d65
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.