Skip to content

gh-127541: Update os.walk example #127765

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 11 commits into from
Mar 29, 2025
Merged

Conversation

totosuki
Copy link
Contributor

@totosuki totosuki commented Dec 9, 2024

I updated the example to exclude __pycache__ directories instead of CVS.
While the issue suggested replacing CVS with .git, a comment pointed out that .git is usually found only in the root directory, making it not equivalent to CVS, which can appear in multiple subdirectories.
On the other hand, __pycache__ directories often appear across various levels of a directory tree, making them a more practical modern example!


📚 Documentation preview 📚: https://cpython-previews--127765.org.readthedocs.build/

@ghost
Copy link

ghost commented Dec 9, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@totosuki totosuki requested a review from picnixz December 9, 2024 16:25
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@totosuki totosuki requested a review from picnixz December 9, 2024 22:06
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a better example. But look also at the fwalk() example and docstrings.

@bedevere-app
Copy link

bedevere-app bot commented Dec 9, 2024

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@totosuki
Copy link
Contributor Author

I have made the requested changes; please review again.

@bedevere-app
Copy link

bedevere-app bot commented Dec 10, 2024

Thanks for making the requested changes!

@serhiy-storchaka: please review the changes made to this pull request.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@totosuki
Copy link
Contributor Author

Thank you!
You're absolutely right that going into .git isn't ideal. I'll update it to python/Lib/xml now.

@totosuki
Copy link
Contributor Author

Hi @gpshead , just pinging in case this PR was missed. Appreciate any final review!

Copy link
Member

@gpshead gpshead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! and good practical idea to use __pycache__ for the example directory to skip.

@gpshead gpshead merged commit a594998 into python:main Mar 29, 2025
38 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Mar 29, 2025
@gpshead gpshead added the needs backport to 3.13 bugs and security fixes label Mar 29, 2025
@miss-islington-app
Copy link

Thanks @totosuki for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 29, 2025
Update os.walk example to be more modern, skip `__pycache__` dirs rather than `CVS` dirs.
(cherry picked from commit a594998)

Co-authored-by: Totosuki <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Mar 29, 2025

GH-131869 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Mar 29, 2025
gpshead pushed a commit that referenced this pull request Mar 29, 2025
gh-127541: Update os.walk example (GH-127765)

Update os.walk example to be more modern, skip `__pycache__` dirs rather than `CVS` dirs.
(cherry picked from commit a594998)

Co-authored-by: Totosuki <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 FreeBSD Refleaks 3.x (tier-3) has failed when building commit a594998.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1613/builds/1042) and take a look at the build logs.
  4. Check if the failure is related to this commit (a594998) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1613/builds/1042

Failed tests:

  • test.test_concurrent_futures.test_process_pool

Failed subtests:

  • test_idle_process_reuse_one - test.test_concurrent_futures.test_process_pool.ProcessPoolSpawnProcessPoolExecutorTest.test_idle_process_reuse_one

Test leaking resources:

  • test_process_pool: memory blocks

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/buildbot/buildarea/3.x.ware-freebsd.refleak/build/Lib/test/test_concurrent_futures/test_process_pool.py", line 146, in test_idle_process_reuse_one
    self.assertEqual(len(executor._processes), 1)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 2 != 1


Traceback (most recent call last):
  File "/buildbot/buildarea/3.x.ware-freebsd.refleak/build/Lib/test/support/__init__.py", line 814, in gc_collect
    gc.collect()
ResourceWarning: unclosed <ssl.SSLSocket fd=6, family=2, type=1, proto=0, laddr=('127.0.0.1', 40156)>
.


Traceback (most recent call last):
  File "/buildbot/buildarea/3.x.ware-freebsd.refleak/build/Lib/test/support/__init__.py", line 814, in gc_collect
    gc.collect()
ResourceWarning: unclosed <ssl.SSLSocket fd=7, family=2, type=1, proto=0, laddr=('127.0.0.1', 46237)>
.


Traceback (most recent call last):
  File "/buildbot/buildarea/3.x.ware-freebsd.refleak/build/Lib/test/support/__init__.py", line 814, in gc_collect
    gc.collect()
ResourceWarning: unclosed <ssl.SSLSocket fd=6, family=2, type=1, proto=0, laddr=('127.0.0.1', 39619)>
.test__all__ (test.test_ftplib.MiscTestCase.test__all__) ... ok

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 CentOS9 NoGIL Refleaks 3.13 (tier-1) has failed when building commit 9ffa80f.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1605/builds/597) and take a look at the build logs.
  4. Check if the failure is related to this commit (9ffa80f) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/1605/builds/597

Failed tests:

  • test_free_threading

Test leaking resources:

  • test_free_threading: memory blocks

Summary of the results of the build (if available):

==

Click to see traceback logs
remote: Enumerating objects: 7, done.        
remote: Counting objects:  14% (1/7)        
remote: Counting objects:  28% (2/7)        
remote: Counting objects:  42% (3/7)        
remote: Counting objects:  57% (4/7)        
remote: Counting objects:  71% (5/7)        
remote: Counting objects:  85% (6/7)        
remote: Counting objects: 100% (7/7)        
remote: Counting objects: 100% (7/7), done.        
remote: Total 7 (delta 6), reused 7 (delta 6), pack-reused 0 (from 0)        
From https://github.com/python/cpython
 * branch                    3.13       -> FETCH_HEAD
Note: switching to '9ffa80f21edcfec5092388b8b7f3cc7dd29692bb'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 9ffa80f21ed [3.13] gh-127541: Update os.walk example (GH-127765) (GH-131869)
Switched to and reset branch '3.13'

configure: WARNING: no system libmpdecimal found; falling back to bundled libmpdecimal (deprecated and scheduled for removal in Python 3.15)

make: *** [Makefile:2240: buildbottest] Error 2

@picnixz picnixz added the needs backport to 3.12 only security fixes label Mar 29, 2025
@miss-islington-app
Copy link

Thanks @totosuki for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 29, 2025
Update os.walk example to be more modern, skip `__pycache__` dirs rather than `CVS` dirs.
(cherry picked from commit a594998)

Co-authored-by: Totosuki <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Mar 29, 2025

GH-131873 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Mar 29, 2025
picnixz added a commit that referenced this pull request Mar 29, 2025
gh-127541: Update os.walk example (GH-127765)

Update os.walk example to be more modern, skip `__pycache__` dirs rather than `CVS` dirs.
(cherry picked from commit a594998)

Co-authored-by: Totosuki <[email protected]>
Co-authored-by: Bénédikt Tran <[email protected]>
seehwan pushed a commit to seehwan/cpython that referenced this pull request Apr 16, 2025
Update os.walk example to be more modern, skip `__pycache__` dirs rather than `CVS` dirs.

Co-authored-by: Bénédikt Tran <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants